🌐
W3Schools
w3schools.io › file › json-cheatsheet
JSON cheatsheet complete tutorial with examples - w3schools
... The object contains key and value pairs and the Array contains a group of objects enclosed in a square bracket[]. { "roles": [ {"name": "admin", "id": 1`}, {"name": "sales", "id": 2} ] } Two-dimensional arrays are an array of arrays.
🌐
W3Schools
w3schools.io › json-sample-examples
Learn JSON sample examples - w3schools
JSON Example contains an array ... { "roles": ["admin", "employee", "user", "visitor"] } Nested JSON Object The object contains a key and value....
🌐
W3Schools
w3schools.in › json › objects
JSON Objects - W3Schools
For this, the syntax will be: ... ... and the value can be either string or a numeric value. Let us take an example where a JSON file will store professor's data and their salaries....
🌐
W3Schools
w3schools.com › js › js_json_objects.asp
JSON Literals
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... JSON object literals are surrounded by curly braces {}.
🌐
W3Schools
w3schools.com › js › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
W3Schools
w3schools.com › js › js_json_arrays.asp
JSON Arrays
In JSON, array values must be of type string, number, object, array, boolean or null. In JavaScript, array values can be all of the above, plus any other valid JavaScript expression, including functions, dates, and undefined. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
W3Schools
w3schools.io › file › yaml-array-objects
YAML equivalent of an array of objects in JSON - w3schools
This tutorial covers How to write an object, an array of objects, and nested object array in YAML with examples json to yaml mapping array nested objects
🌐
Plain English
python.plainenglish.io › data-extraction-parse-a-3-nested-json-object-23cb978b66ad
Data Extraction: Parse a 3-Nested JSON Object and Convert it to a pandas dataframe | by Tejeswini | Python in Plain English
June 10, 2021 - www.w3schools.com · A JSON object is a collection of key and value pairs. For example, { ‘data’ : [ {‘screen_ID’ : ‘63’, in this instance ‘data’ and ‘screen_ID’ are the keys, and ‘63’ is the value. Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null). Join Medium for free to get updates from this writer. Subscribe · Subscribe · So, what is a Nested-JSON?
🌐
W3Resource
w3resource.com › JSON › introduction.php
JSON Tutorial | w3resource
Then '"Price"' label contains an array, which is turn contains two separate objects. Another example of nesting. Also, notice that numbers are not enclosed by quotations. The name behind popularizing the JSON is Douglas Crockford.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-access-and-process-nested-objects-arrays-or-json
How to Access and Process Nested Objects, Arrays, or JSON? - GeeksforGeeks
... const o1 = { o2: { name: "Sourav", contact: { email: "sourav@example.com", phone: "123-456-7890" } } }; // Using dot notation console.log(o1.o2.contact.email); // Using bracket notation console.log(o1["o2"]["contact"]["phone"]);
Published   July 23, 2025
🌐
Retool
community.retool.com › 💬 queries and resources
Accessing data in nested json - 💬 Queries and Resources - Retool Forum
March 5, 2023 - hey everyone, please excuse my beginners issues but I am having some really hard time accessing items in nested json. At the moment I am trying to simply get the title url (found in source) main_name (found in actors) aliases (also found in actors) from json that looks like this { "id": "123456789", "title": "brad pitt on the rise", "authors": "brian j. robb", "language": "EN", "sources": [{ "id": "123456789", "name": "imdb", "url": "https://www.imdb.com/name/nm00000...
🌐
Liquid-technologies
blog.liquid-technologies.com › advanced-data-structures-in-json-part-3-of-4
Advanced Data Structures in JSON: Nested Objects & Arrays
July 4, 2025 - This allows you to create hierarchical structures, grouping related attributes together.2 ... Representing “has-a” relationships: For example, a user object “has an” address object.
🌐
W3Schools
w3schools.com › js › js_json.asp
W3Schools.com
JSON Intro JSON Syntax JSON vs XML JSON Data Types JSON Parse JSON Stringify JSON Objects JSON Arrays JSON Server JSON PHP JSON HTML JSON JSONP JS jQuery · jQuery Selectors jQuery HTML jQuery CSS jQuery DOM JS Graphics · JS Graphics JS Canvas JS Plotly JS Chart.js JS Google Chart JS D3.js JS Examples
🌐
Plain English
plainenglish.io › blog › data-extraction-parse-a-3-nested-json-object-23cb978b66ad
Data Extraction: Parse a 3-Nested JSON Object and Convert it to a pandas dataframe
June 6, 2021 - Detailed documentation can be looked ... =…*www.w3schools.com · A JSON object is a collection of key and value pairs. For example, { 'data’ : [ {'screen_ID’ : '63’, in this instance 'data’ and 'screen_ID’ are the keys, and '63’ is the value. Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null). So, what is a Nested-JS...
Top answer
1 of 5
25

The first code is an example of Javascript code, which is similar, however not JSON. JSON would not have 1) comments and 2) the var keyword

You don't have any comments in your JSON, but you should remove the var and start like this:

orders: {

The [{}] notation means "object in an array" and is not what you need everywhere. It is not an error, but it's too complicated for some purposes. AssociatedDrug should work well as an object:

"associatedDrug": {
                "name":"asprin",
                "dose":"",
                "strength":"500 mg"
          }

Also, the empty object labs should be filled with something.

Other than that, your code is okay. You can either paste it into javascript, or use the JSON.parse() method, or any other parsing method (please don't use eval)

Update 2 answered:

obj.problems[0].Diabetes[0].medications[0].medicationsClasses[0].className[0].associatedDrug[0].name

returns 'aspirin'. It is however better suited for foreaches everywhere

2 of 5
19

I successfully solved my problem. Here is my code:

The complex JSON object:

   {
    "medications":[{
            "aceInhibitors":[{
                "name":"lisinopril",
                "strength":"10 mg Tab",
                "dose":"1 tab",
                "route":"PO",
                "sig":"daily",
                "pillCount":"#90",
                "refills":"Refill 3"
            }],
            "antianginal":[{
                "name":"nitroglycerin",
                "strength":"0.4 mg Sublingual Tab",
                "dose":"1 tab",
                "route":"SL",
                "sig":"q15min PRN",
                "pillCount":"#30",
                "refills":"Refill 1"
            }],
            "anticoagulants":[{
                "name":"warfarin sodium",
                "strength":"3 mg Tab",
                "dose":"1 tab",
                "route":"PO",
                "sig":"daily",
                "pillCount":"#90",
                "refills":"Refill 3"
            }],
            "betaBlocker":[{
                "name":"metoprolol tartrate",
                "strength":"25 mg Tab",
                "dose":"1 tab",
                "route":"PO",
                "sig":"daily",
                "pillCount":"#90",
                "refills":"Refill 3"
            }],
            "diuretic":[{
                "name":"furosemide",
                "strength":"40 mg Tab",
                "dose":"1 tab",
                "route":"PO",
                "sig":"daily",
                "pillCount":"#90",
                "refills":"Refill 3"
            }],
            "mineral":[{
                "name":"potassium chloride ER",
                "strength":"10 mEq Tab",
                "dose":"1 tab",
                "route":"PO",
                "sig":"daily",
                "pillCount":"#90",
                "refills":"Refill 3"
            }]
        }
    ],
    "labs":[{
        "name":"Arterial Blood Gas",
        "time":"Today",
        "location":"Main Hospital Lab"      
        },
        {
        "name":"BMP",
        "time":"Today",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"BNP",
        "time":"3 Weeks",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"BUN",
        "time":"1 Year",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"Cardiac Enzymes",
        "time":"Today",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"CBC",
        "time":"1 Year",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"Creatinine",
        "time":"1 Year",
        "location":"Main Hospital Lab"  
        },
        {
        "name":"Electrolyte Panel",
        "time":"1 Year",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"Glucose",
        "time":"1 Year",
        "location":"Main Hospital Lab"  
        },
        {
        "name":"PT/INR",
        "time":"3 Weeks",
        "location":"Primary Care Clinic"    
        },
        {
        "name":"PTT",
        "time":"3 Weeks",
        "location":"Coumadin Clinic"    
        },
        {
        "name":"TSH",
        "time":"1 Year",
        "location":"Primary Care Clinic"    
        }
    ],
    "imaging":[{
        "name":"Chest X-Ray",
        "time":"Today",
        "location":"Main Hospital Radiology"    
        },
        {
        "name":"Chest X-Ray",
        "time":"Today",
        "location":"Main Hospital Radiology"    
        },
        {
        "name":"Chest X-Ray",
        "time":"Today",
        "location":"Main Hospital Radiology"    
        }
    ]
}

The jQuery code to grab the data and display it on my webpage:

$(document).ready(function() {
var items = [];

$.getJSON('labOrders.json', function(json) {
  $.each(json.medications, function(index, orders) {
    $.each(this, function() {
        $.each(this, function() {
            items.push('<div class="row">'+this.name+"\t"+this.strength+"\t"+this.dose+"\t"+this.route+"\t"+this.sig+"\t"+this.pillCount+"\t"+this.refills+'</div>'+"\n");
        });
    });
  });

  $('<div>', {
    "class":'loaded',
    html:items.join('')
  }).appendTo("body");

});

});

🌐
DEV Community
dev.to › iamcymentho › demystifying-nested-data-a-guide-to-accessing-and-processing-objects-arrays-and-json-in-javascript-34im
Demystifying Nested Data: A Guide to Accessing and Processing Objects, Arrays, and JSON in JavaScript - DEV Community
September 15, 2023 - In JavaScript, you can parse JSONdata from a string into a JavaScript object using the JSON.parse() method: ... This section provides real-world scenarios and code examples demonstrating how to work with nested data.
🌐
QA With Experts
qawithexperts.com › article › javascript › nested-and-complex-json-examples › 446
Nested and Complex JSON examples - QA With Experts
June 26, 2024 - var objct = JSON.parse('{"data": [{ "MainId": 1111,"firstName": "Sherlock","lastName": "Homes","categories": [ {"CategoryID": 1,"CategoryName": "Example"}]},{"MainId": 122,"firstName": "James", "lastName": "Watson", "categories": [{ "CategoryID": 2,"CategoryName": "Example2"}]}], "messages": [], "success": true }'); console.log(objct.data[1].firstName); //output //James · That's it, these are some of the complex and nested JSON example, which can be helpful for front-end or back-end developer.
🌐
Phrase
support.phrase.com › hc › en-us › articles › 6111330881692--JSON-Nested-Strings
.JSON - Nested (Strings) – Phrase
AI chatbots can be very effective at generating a list of keys from a .JSON file. { "boolean_key": "--- true\n", "empty_string_translation": "", "key_with_description": "Check it out! This key has a description! (At least in some formats)", "key_with_line-break": "This translations contains\na line-break.", "nested": { "deeply": { "key": "Wow, this key is nested even deeper."
Top answer
1 of 4
4

Your input string is wrong

<p id="demo"></p>

 <script>
 var text='{ "rajaongkir":{ '
+ '  "query":{'
+'     "origin":"501",'
+'     "destination":"114",'
+'     "weight":1700,'
+'     "courier":"jne"'
+'  },'
+'  "status":{'
+'     "code":200,'
+'     "description":"OK"'
+'  },'
+'  "origin_details":{'
+'     "city_id":"501",'
+'     "province_id":"5",'
+'     "province":"DI Yogyakarta",'
+'     "type":"Kota",'
+'     "city_name":"Yogyakarta",'
+'     "postal_code":"55000"'
+'  },'
+'  "destination_details":{'
+'     "city_id":"114",'
+'     "province_id":"1",'
+'     "province":"Bali",'
+'     "type":"Kota",'
+'     "city_name":"Denpasar",'
+'     "postal_code":"80000"'
+'  },'
+'  "results":['
+'     {'
+'        "code":"jne",'
+'        "name":"Jalur Nugraha Ekakurir (JNE)",'
+'        "costs":['
+'           {'
+'              "service":"OKE",'
+'              "description":"Ongkos Kirim Ekonomis",'
+'              "cost":['
+'                 {'
+'                    "value":38000,'  //<<<<<<  GET THIS VALUE
+'                    "etd":"4-5",'
+'                    "note":""'
+'                 }'
+'              ]'
+'           },'
+'           {'
+'              "service":"REG",'
+'              "description":"Layanan Reguler",'
+'              "cost":['
+'                 {'
+'                    "value":44000,'
+'                    "etd":"2-3",'
+'                    "note":""'
+'                 }'
+'              ]'
+'           },'
+'           {'
+'              "service":"SPS",'
+'              "description":"Super Speed",'
+'              "cost":['
+'                 {'
+'                    "value":349000,'
+'                    "etd":"",'
+'                    "note":""'
+'                 }'
+'              ]'
+'           },'
+'           {'
+'              "service":"YES",'
+'              "description":"Yakin Esok Sampai",'
+'              "cost":['
+'                 {'
+'                    "value":98000,'
+'                    "etd":"1-1",'
+'                    "note":""'
+'                 }'
+'              ]'
+'           }'
+'        ]'
+'     }'
+'  ]}}';  
   obj=JSON.parse(text);
   document.getElementById("demo").innerHTML=
   obj.rajaongkir.results[0].costs[0].cost[0].value;
   </script>
2 of 4
2

Your JSON is not a valid string literal. There are no line breaks allowed, unless you end every line with a \.

If you add these \, everything is fine:

https://jsfiddle.net/ec3n6f20/