Open theking2 opened 1 month ago
We have said exactly this:
You can include the same basic data types inside JSON as you can in a standard JavaScript object — strings, numbers, arrays, booleans, and other object literals.
With a lot other caveats about how to properly author JSON. I think it's straightforward to conclude about allowed data types, so no additional content is necessary. Unless I'm misreading your suggestion?
Yes, you made a good case there. I had a bit of a fight with a Date type in a JSON api. Date is an object but cannot be used in a date string only property. Object literals can also store methods. I'm not sure how to describe properly but JSON restricts the data types to strings, int, floats, and arrays and objects of those.
MDN URL
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON
What specific section or headline is this issue about?
JSON structure
What information was incorrect, unhelpful, or incomplete?
Allowed data types.
What did you expect to see?
Data types inside JSON are a bit restricted compaired to standard JavaScript. The only allowed types are objects, arrays, string and number literals as well as "true", "false" and "null".
Do you have any supporting links, references, or citations?
(https://www.json.org/json-en.html)
Do you have anything more you want to share?
https://www.json.org/json-en.html
MDN metadata
Page report details
* Folder: `en-us/learn/javascript/objects/json` * MDN URL: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/learn/javascript/objects/json/index.md * Last commit: https://github.com/mdn/content/commit/d71da812ee94c20658cb1916a123a42254ea545c * Document last modified: 2024-08-07T22:02:28.000Z