JSON Format or just a String

Hello

I get the following after a PHP query:

{“taboo_usdt”:{“result”:“true”,“last”:“0.001945”,“lowestAsk”:“0.001949”,“highestBid”:“0.001937”,“percentChange”:“-2.35”,“baseVolume”:“19767.762677535”,“quoteVolume”:“9948958.8580992”,“high24hr”:“0.002298”,“low24hr”:“0.001915”},“op3l_usdt”:{“result”:“true”,“last”:“3.8063”,“lowestAsk”:“3.7757”,“highestBid”:“3.7231”,“percentChange”:“12.65”,“baseVolume”:“2793.436071”,“quoteVolume”:“797.255”,“high24hr”:“3.8063”,
“low24hr”:“3.1474”}"

My question is this already in JSON format or just a string? I want to read the “last” entry using JSON. after lDynCoinGateIO=JSON.parse(CStr(lintRequestGateIO.responseText)
and console.log(lDynCoinGateIO[“taboo_usdt”].last) I get the error “last” is not defined.

How can I solve this?

Thanks for your answer.

Kind regards

Ramon

Is this the complete output? I notice the output starts with a {, buts ends with a ". Whether is a string or a JSON object, the first and last characters should correspond to each other.

You can validate JSON data on this site.

Hello
Many thanks for your answer. The Response from server is in JSON Format, i have checked with the Site. Now the Response looks like:

{‘taboo_usdt’:{‘result’: ‘true’,‘last’: ‘0.001945’,‘lowestAsk’: ‘0.001949’,‘highestBid’: ‘0.001937’}, “op3l_usdt”:“result”:“true”,“last”:“3.8063”,“lowestAsk”:“3.7757”,“highestBid”:“3.7231”,“percentChange”:“12.65”,“baseVolume”:“2793.436071”,“quoteVolume”:“797.255”,“high24hr”:“3.8063”,
“low24hr”:“3.1474”}}

am a bit confused, if the response is already JSON does it no longer need JSON.parse? or. how can I do the query with an array? It would be awesome if it
worked with, for example, [“taboo_usdt”].last.

many thanks for your support

kind regards

Ramon

If you’re not sure if it’s JSON or a string, use the typeof() function. If it’s a string, using JSON.parse to convert to an object. If it’s an object, you should be able to use it as you are hoping.

Hello

i have checked with the typeof and its a string, then i use JSON.parse but i can’t use the [“taboo_usdt”].last from the JSON → Error

Uncaught TypeError: Cannot read properties of undefined (reading ‘last’)
at Object.GateIO_Done (code.js:227:46)
at i (jquery.js:2:27065)
at Object.fireWith [as resolveWith] (jquery.js:2:27828)
at z (jquery.js:4:11827)
at XMLHttpRequest. (jquery.js:4:15387)

What does your JSON.parse() statement look like?

Hello

works, the following entry in the PHP file was the solution. thanks for the support

header(‘Content-type: application/json’);

kind regards

Ramon