Learn Courses My Dashboard

JSON Parsing Parameter

Hello there, I hope I am not the only one who encounters this problem once in his life.
So, I want to create the structures for the respective JSON data, but at a parameter I don’t know what to do:

“Time Series (5min)”: {
“2021-07-07 20:00:00”: {
“1. open”: “280.3400”,
“2. high”: “280.4000”,
“3. low”: “280.3400”,
“4. close”: “280.4000”,
“5. volume”: “1671”
},
“2021-07-07 19:55:00”: {
“1. open”: “280.2500”,
“2. high”: “280.2600”,
“3. low”: “280.2500”,
“4. close”: “280.2600”,
“5. volume”: “900”
},

“TimeSeries” is a structure and contains multiple structures of the type bellow it. But how shall I name that type, because is continuously changing…? From 2021-07-07 20:00:00 to 2021-07-07 19:55:00 and so on.

If someone can help me here as soon as possible Ill be very grateful. Thank you!

Looks to me that the JSON sample you have is not valid.

Can you share the API you are using?

{
“Meta Data”: {
“1. Information”: “Intraday (5min) open, high, low, close prices and volume”,
“2. Symbol”: “MSFT”,
“3. Last Refreshed”: “2021-07-07 20:00:00”,
“4. Interval”: “5min”,
“5. Output Size”: “Compact”,
“6. Time Zone”: “US/Eastern”
},
“Time Series (5min)”: {
“2021-07-07 20:00:00”: {
“1. open”: “280.3400”,
“2. high”: “280.4000”,
“3. low”: “280.3400”,
“4. close”: “280.4000”,
“5. volume”: “1671”
},
“2021-07-07 19:55:00”: {
“1. open”: “280.2500”,
“2. high”: “280.2600”,
“3. low”: “280.2500”,
“4. close”: “280.2600”,
“5. volume”: “900”
},
“2021-07-07 19:50:00”: {
“1. open”: “280.2600”,
“2. high”: “280.2600”,
“3. low”: “280.2500”,
“4. close”: “280.2500”,
“5. volume”: “4951”
},
(…) //there are another 100
}
}

You might find this tool helpful in generating the required structs for the data you have.

https://app.quicktype.io

You can copy the entire JSON API output and plug into this tool. That way any null entires can be taken into account and create the required Optionals.

The tool is by no means the definitive answer but will give you a good guide.

1 Like

Thank you, I appreciate your help!