This is just a JavaScript object. If you are new to JavaScript, I suggest starting with our JavaScript curriculum. If you work through this curriculum section, you should have a much better idea of how to extract the data you need from this object. Answer from camperextraordinaire on forum.freecodecamp.org
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Response › json
Response: json() method - Web APIs | MDN - Mozilla
When the fetch is successful, we read and parse the data using json(), then read values out of the resulting objects as you'd expect and insert them into list items to display our product data. ... const myList = document.querySelector("ul"); const myRequest = new Request("products.json"); fetch(myRequest) .then((response) => response.json()) .then((data) => { for (const product of data.products) { const listItem = document.createElement("li"); listItem.appendChild(document.createElement("strong")).textContent = product.Name; listItem.append(` can be found in ${product.Location}. Cost: `); listItem.appendChild(document.createElement("strong")).textContent = `£${product.Price}`; myList.appendChild(listItem); } }) .catch(console.error);
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Response › json_static
Response: json() static method - Web APIs | MDN
The json() static method of the Response interface returns a Response that contains the provided JSON data as body, and a Content-Type header which is set to application/json. The response status, status message, and additional headers can also be set.
Discussions

How to handle JSON like response in javascript?
I’m currently using jira-client to create a jira automation utility and response to getting all issues assigned to a user from that API looks something like this { expand: 'schema,names', startAt: 0, maxResults: 5… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
February 2, 2023
How to read JSON(server response) in Javascript? - Stack Overflow
The format you've got now is pretty fugly to work with. 2012-03-18T01:18:20.357Z+00:00 ... If you got here trying to find out how to read from [Response object] (as I did) - this what can help: - if you use fetch don't forget about res.json() before logging in console More on stackoverflow.com
🌐 stackoverflow.com
What exactly does response.json() do?
the Response Object that you get promised from your fetch contains a Datastream which needs to be evaluated before you can do anything meaningful with it. That Datastream is in memory so your code would need to access it in a non-blocking way, thus the Response Object exposes two (or more?) functions that will return a promise once the Datastream had been converted. Those functions are .json() which tries to resolve the Datastream to a json and .text() which resolves the Datastream into plaintext. So in a sense yes, a Promise inside a Promise. More on reddit.com
🌐 r/learnjavascript
15
17
August 3, 2022
JavaScript fetch API - Why does response.json() return a promise object (instead of JSON)? - Stack Overflow
253 Why does .json() return a promise, but not when it passes through .then()? ... 2 Is there a best practice ("right way") for inspecting fetch response object in vanilla html/css/js app? ... 3368 Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Wyday
wyday.com › limelm › help › api › response.json
JSON Response Format • LimeLM
In JavaScript, displaying a list of a user's pkeys is then straight forward: function jsonLimeLMApi(rsp){ if (rsp.stat !== "ok"){ // something broke! return; } for (var i=0; i < rsp.pkeys.pkey.length; i++){ var pkey = rsp.pkeys.pkey[i]; var div = document.createElement('div'); var txt = document.createTextNode(pkey.key); div.appendChild(txt); document.body.appendChild(div); } } Failure responses also call the jsonLimeLMApi() method, but with a different JSON object.
Top answer
1 of 6
13

If you're trying to use JSON format, your problem is that the data within the [...] also needs to be in pairs, and grouped in {...} like here.

For instance,

{ 
      "sales": [ 
         { "firstname" : "John", "lastname" : "Brown" },
         { "firstname" : "Marc", "lastname" : "Johnson" }
      ] // end of sales array
    }

So you might have:

{"COLUMNS": [ 
  {"REGISTRATION_DT" : "19901212", "USERNAME" : "kudos", "PASSWORD" : "tx91!#1", ... },
  {"REGISTRATION_DT" : "19940709", "USERNAME" : "jenny", "PASSWORD" : "fxuf#2", ... },
  {"REGISTRATION_DT" : "20070110", "USERNAME" : "benji12", "PASSWORD" : "rabbit19", ... }
 ]
}

If the server is sending you something which you refer to as res, you can just do this to parse it in your Javascript:

var o=JSON.parse(res);

You can then cycle through each instance within columns like follows:

for (var i=0;i<o.COLUMNS.length;i++)
{  
        var date = o.COLUMNS[i].REGISTRATION_DT; .... 
}
2 of 6
7

Please take a look on example code snippet as shown below

Example JSON

{
"name": "mkyong",
"age": 30,
"address": {
    "streetAddress": "88 8nd Street",
    "city": "New York"
},
"phoneNumber": [
    {
        "type": "home",
        "number": "111 111-1111"
    },
    {
        "type": "fax",
        "number": "222 222-2222"
    }
]
}

Here is the code to read the json

<script>
   var data = '{"name": "mkyong","age": 30,"address": {"streetAddress": "88 8nd Street","city": "New York"},"phoneNumber": [{"type": "home","number": "111 111-1111"},{"type": "fax","number": "222 222-2222"}]}';

var json = JSON.parse(data);
        
alert(json["name"]); //mkyong
alert(json.name); //mkyong

alert(json.address.streetAddress); //88 8nd Street
alert(json["address"].city); //New York
        
alert(json.phoneNumber[0].number); //111 111-1111
alert(json.phoneNumber[1].type); //fax
        
alert(json.phoneNumber.number); //undefined
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
Note: If you are having trouble following the dot/bracket notation we are using to access the JavaScript object, it can help to have the superheroes.json file open in another tab or your text editor, and refer to it as you look at our JavaScript. You should also refer back to our JavaScript object basics article for more information on dot and bracket notation. Finally, we need to call our top-level populate() function: ... The above example was simple in terms of accessing the JavaScript object, because we converted the network response directly into a JavaScript object using response.json().
🌐
ReqBin
reqbin.com › req › 4gvqbdi1 › json-response-format-example
What is the correct JSON Response Format?
December 23, 2022 - Click Send to execute the JSON Response Format example online and see the results. ... JavaScript Object Notation (JSON) is a language-neutral, text-based data interchange format ...
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_json.asp
JavaScript JSON
The JSON format is syntactically identical to the code for creating JavaScript objects. Because of this, a JavaScript program can easily convert JSON data into native JavaScript objects.
🌐
Grafana
grafana.com › docs › k6 › latest › javascript-api › k6-http › response › response-json
Response.json( [selector] ) | Grafana k6 documentation
import http from 'k6/http'; export default function () { const res = http.get('https://quickpizza.grafana.com/api/json?foo=bar'); console.log(res.json()); } ... Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
🌐
ReqBin
reqbin.com › code › javascript › wc3qbk0b › javascript-fetch-json-example
How do I fetch JSON using JavaScript Fetch API?
November 24, 2023 - The response.json() method reads the data returned by the server and returns a Promise that resolves with a JSON object. If you are expecting a text, call the response.text() method.
🌐
Reddit
reddit.com › r/learnjavascript › what exactly does response.json() do?
r/learnjavascript on Reddit: What exactly does response.json() do?
August 3, 2022 -

Code:

fetch('http://api-to-call.com/endpoint').then(response => {
  if (response.ok) {
    return response.json();
  }
  else {
    throw new Error('Request failed!');
  }
}, networkError => console.log(networkError.message)
).then(jsonResponse => {
    console.log(jsonResponse)
});

From my current understanding, the first .then() returns a promise that resolves to response.json(). However, after reading up on it a little bit, it seems response.json() returns a promise itself. So it's a promise within a promise?

Also, reponse.json() converts a response object to JSON too? I don't get it.

I'd greatly appreciate some clarity on this

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-check-if-the-response-of-a-fetch-is-a-json-object-in-javascript
How to Check if the Response of a Fetch is a JSON Object in JavaScript? - GeeksforGeeks
August 5, 2025 - If the response is successfully parsed as JSON, we assign it to the responseData variable and log it to the console. If any errors occur during the fetch operation or parsing, we catch and handle them in the catch block. Example: The below code will explain the use of the Content-Type header to check the response format.
🌐
W3Schools
w3schools.com › js › js_json_syntax.asp
JSON Syntax
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value: ... JSON names require double quotes. The JSON format is almost identical to JavaScript objects.
🌐
Stack Overflow
stackoverflow.blog › 2022 › 06 › 02 › a-beginners-guide-to-json-the-data-format-for-the-internet
A beginner's guide to JSON, the data format for the internet - Stack Overflow
For example, it can be called on ... JSON.stringify(object) which takes a JavaScript object and returns a string of JSON, which can then be transmitted in an API request or response. JSON isn’t required by REST or GraphQL, both very popular API formats....
🌐
Wikipedia
en.wikipedia.org › wiki › JSON
JSON - Wikipedia
March 6, 2005 - Upon discovery of early Ajax capabilities, digiGroups, Noosh, and others used frames to pass information into the user browsers' visual field without refreshing a Web application's visual context, realizing real-time rich Web applications using only the standard HTTP, HTML, and JavaScript capabilities of Netscape 4.0.5+ and Internet Explorer 5+. Crockford then found that JavaScript could be used as an object-based messaging format for such a system. The system was sold to Sun Microsystems, Amazon.com, and EDS. JSON was based on a subset of the JavaScript scripting language (specifically, Standard ECMA-262 3rd Edition—December 1999) and is commonly used with JavaScript, but it is a language-independent data format.
🌐
Dmitri Pavlutin
dmitripavlutin.com › fetch-with-json
How to Use fetch() with JSON
January 23, 2023 - Let's fetch from the path /api/names a list of persons in JSON format: ... await fetch('/api/names') starts a GET request, and returns a response object when the request completes. Then, from the server response, you can extract the JSON into a plain JavaScript object using await response.json() (note: response.json() returns a promise!).
🌐
Reddit
reddit.com › r/node › standardized formats for json responses and requests.
r/node on Reddit: Standardized formats for JSON responses and requests.
June 16, 2023 -

I'm working on an Express API, and I was curious what the current consensus is on JSON formats for API requests and responses? I've been using Google's JSON style guide, which I've enjoyed. Do you all have preferences? Are there pitfalls to watch out for?

🌐
Stack Overflow
stackoverflow.com › questions › 75643510 › how-do-i-convert-response-message-to-json-in-javascript
How do I convert response.message to json in javascript? - Stack Overflow
Not sure what message is, but it's typically done with just response.json(). ... Save this answer. Show activity on this post. As stated in the documentation, you can set the whole response to json and then call the message part.
🌐
ReqBin
reqbin.com › req › gzezk8d5 › json-response-example
How do I return JSON in response?
JSON defines a small set of formatting rules for the portable representation of structured data. JSON can represent four primitive types (strings, numbers, boolean values, and null) and two structured types (objects and arrays). JSON is used to exchange data between applications written in many programming languages, including JavaScript, Java, C ++, C #, Go, PHP, Python, and many others.