Yes there are a couple of standards (albeit some liberties on the definition of standard) that have emerged:
- JSON API - JSON API covers creating and updating resources as well, not just responses.
- JSend - Simple and probably what you are already doing.
- OData JSON Protocol - Very complicated.
- HAL - Like OData but aiming to be HATEOAS like.
There are also JSON API description formats:
- Swagger
- JSON Schema (used by swagger but you could use it stand alone)
- WADL in JSON
- RAML
- HAL because HATEOAS in theory is self describing.
Top answer 1 of 16
894
Yes there are a couple of standards (albeit some liberties on the definition of standard) that have emerged:
- JSON API - JSON API covers creating and updating resources as well, not just responses.
- JSend - Simple and probably what you are already doing.
- OData JSON Protocol - Very complicated.
- HAL - Like OData but aiming to be HATEOAS like.
There are also JSON API description formats:
- Swagger
- JSON Schema (used by swagger but you could use it stand alone)
- WADL in JSON
- RAML
- HAL because HATEOAS in theory is self describing.
2 of 16
327
Google JSON guide
Success response return data
{
"data": {
"id": 1001,
"name": "Wing"
}
}
Error response return error
{
"error": {
"code": 404,
"message": "ID not found"
}
}
and if your client is JS, you can use if ("error" in response) {} to check if there is an error.
ReqBin
reqbin.com › req › 4gvqbdi1 › json-response-format-example
What is the correct JSON Response Format?
If the Content-Length HTTP header ... transfer encoding format. In this JSON Response Format example, we send a request to the ReqBin echo URL to get JSON ......
Videos
09:22
Format API JSON Response Using @JsonProperty and @JsonInclude - ...
18:24
Learn JSON: A Must-Know Data Format - YouTube
09:15
Getting Structured Output in JSON format - YouTube
20:22
Master OpenAI JSON Response Format for Interactive Websites - YouTube
11:25
Get consistent JSON response from OpenAI / Chat-GPT - YouTube
03:08
How to get OpenAI API response in JSON format reliably🔥: Python ...
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Response › json
Response: json() method - Web APIs | MDN
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);
JSON:API
jsonapi.org
JSON:API — A specification for building APIs in JSON
}, "relationships": { "author": { "data": { "type": "people", "id": "2" } } }, "links": { "self": "http://example.com/comments/5" } }, { "type": "comments", "id": "12", "attributes": { "body": "I like XML better" }, "relationships": { "author": { "data": { "type": "people", "id": "9" } } }, "links": { "self": "http://example.com/comments/12" } }] } The response above contains the first in a collection of “articles”, as well as links to subsequent members in that collection. It also contains resources linked to the article, including its author and comments. Last but not least, links are provided that can be used to fetch or update any of these resources. JSON:API covers creating and updating resources as well, not just responses.
Wyday
wyday.com › limelm › help › api › response.json
JSON Response Format • LimeLM
For instance, limelm.pkey.find has a documented response as follows: <pkeys total="2"> <pkey id="103" key="A84U-ZTZT-V2WI-5KCK-EV5S-3PWK-K2TX" acts="4" acts_used="3"/> <pkey id="104" key="X8ZB-FRRK-PVWX-M3RY-YPE8-ARFM-N2TX" acts="1" acts_used="1"/> </pkeys> ... jsonLimeLMApi({ "stat":"ok", "pkeys": { "total":2, "pkey":[ { "id":"103", "key":"A84U-ZTZT-V2WI-5KCK-EV5S-3PWK-K2TX", "acts":"4", "acts_used":"3" }, { "id":"104", "key":"X8ZB-FRRK-PVWX-M3RY-YPE8-ARFM-N2TX", "acts":"1", "acts_used":"1" } ] } })
Red Hat
docs.redhat.com › en › documentation › red_hat_satellite › 6.2 › html › api_guide › sect-api_guide-understanding_the_json_response_format
2.2. Understanding the JSON Response Format | API Guide | Red Hat Satellite | 6.2 | Red Hat Documentation
Note that :name cannot always be used as a unique identifier, but :id can always be used. The format for a single-object JSON response consists of only the object’s attributes. Below is an example of the format for a single-object JSON response when using the API route GET /api/domains/23 or GET /api/domains/qa.lab.example.com.
JSON Formatter
jsonformatter.curiousconcept.com
JSON Formatter & Validator
Format & Validate JSON To install, just drag the button above into your bookmarks toolbar. Have questions? These are the answers to the questions we are most frequently asked. ... Yes! You can populate and process your JSON data automatically by submitting a GET or POST request (example) with the following query parameters:
JSON Formatter
jsonformatter.org
Best JSON Formatter and JSON Validator: Online JSON Formatter
JSON Format Checker helps to fix the missing quotes, click the setting icon which looks like a screwdriver on the left side of the editor to fix the format. ... JSON Example with all data types including JSON Array.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Response › json_static
Response: json() static method - Web APIs | MDN
The code below creates a Response object with JSON body { my: "data" } and header set to application/json. ... The object has the following properties. Note the body and header are set as expected, and that the default status is set to 200. This example shows how you can create a JSON response ...
W3Schools
w3schools.com › js › js_json_syntax.asp
JSON Syntax
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 data is written as name/value pairs (aka key/value pairs). 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.
ReqBin
reqbin.com › req › gzezk8d5 › json-response-example
How do I return JSON in response?
In this JSON response example, we send a request to the ReqBin echo URL and provide the "Accept: application/json" request header to tell the server that the client is expecting JSON.
Technick
technick.net › guides › software › software_json_api_format
Simple API JSON Response Format · Technick.net
If the responses are stored as logs for auditing or debugging purposes, the new additional fields provide the required what and when information. The API service should always return the above JSON object, even in case of error or panic. This allows to use a consistent parsing method. The API service should always provide two standard GET entry points: Return a list of all available entry points (routes). For example...
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 the body of an API response to give you a usable object. The inverse of this function is 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...
JSON
json.org › example.html
JSON Example
This page shows examples of messages formatted using JSON (JavaScript Object Notation).
JSON:API
jsonapi.org › examples
JSON:API — Examples
Note: The above example URI shows unencoded [ and ] characters simply for readability. In practice, these characters should be percent-encoded, as noted in the base specification. See “Square Brackets in Parameter Names”. Here we want articles objects to have fields title, body and author only and people objects to have name field only. HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "data": [{ "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!", "body": "The shortest article.
Atlassian
developer.atlassian.com › server › crowd › json-requests-and-responses
JSON requests and responses
These samples show the JSON representations that the Crowd REST Resources expect to receive. ... { "name" : "my_username", "first-name" : "My", "last-name" : "Username", "display-name" : "My Username", "email" : "user@example.test", "password" : { "value" : "my_password" }, "active" : true }
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().
JSON Formatter
jsonformatter.org › 1f2489
json response
JSON Format Checker helps to fix the missing quotes, click the setting icon which looks like a screwdriver on the left side of the editor to fix the format. ... JSON Example with all data types including JSON Array.