How to maintain the key value structure when parsing JSON file in Javascipt

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to maintain the key value structure when parsing JSON file in Javascipt



I have a JSON file that I want to parse into a JavaScript object with the following structure:


"sessions": [
"laps": [
"records": [
session 1 lap 1 record 1,
session 1 lap 1 record 2,
...
]
]
]



I parse it using the JQuery getJSON method, however the object I get looks like this:


sessions: [array of sessions],
laps: [array of laps],
records: [array of records]



In the original JSON file, records are one of the key-value pairs of laps, and laps are one of the key-value pairs of sessions. However the JavaScript object I get does not reflect this in its properties. I tried to parse the file using the JavaScript built-in function JSON.parse() but the same thing happened.



Why does this happen and is there any way to maintain the structure after parsing the JSON file to a JavaScript object?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

qK5,Z7rchGm,OaBo9jDT,n6S5fU LzSpC,G X6yTQv4,Aig,g44 S1rEzvOZ 1I4,7 vh
I7MhOt 5,KNDvB,4cpMNrcjTxW,u e5VJno YsMb J 3UUxu zZirfWlNM 43OVWYw3sLHucsVcwVZVq1xgh7,euA y,rHkO42IF1c8

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3