I have a json sample menulist.json
(attached in pastebin) that needs to be read in jsavascript. I'm reading file as mentioned in this answer.
But looks like JavaScript is not reading JSON properly.
Beverages
and Desserts
should be under Menu
. But it doesn't seem to be happening:
Just to verify same json, I pasted that in python shell. It looks like python is reading properly.
Here is my code: HTML
<html>
<head>
...
...
...
<script type="text/javascript" src="menulist.json"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>
...
...
...
</body>
</html
Note : It's not about the ordering or sequence. It's about the child objects not appearing under same key.