You don’t need to use arrays.
JSON values can be arrays, objects, or primitives (numbers or strings).
You can write JSON like this:
{ "stuff": { "onetype": [ {"id":1,"name":"John Doe"}, {"id":2,"name":"Don Joeh"} ], "othertype": {"id":2,"company":"ACME"} }, "otherstuff": { "thing": [[1,42],[2,2]] } }
You can use it like this:
obj.stuff.onetype[0].id obj.stuff.othertype.id obj.otherstuff.thing[0][1] //thing is a nested array or a 2-by-2 matrix. //I'm not sure whether you intended to do that.
Related Posts:
- syntax error: unexpected token <
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- jQuery AJAX cross domain
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Loading local JSON file
- Uncaught TypeError: data.push is not a function
- How to convert selected HTML to Json?
- SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- How to display raw JSON data on a HTML page
- Convert array to JSON
- How to filter JSON Data in JavaScript or jQuery?
- How to add a button dynamically using jquery
- Complex JSON nesting of objects and arrays
- Uncaught SyntaxError: Unexpected token with JSON.parse
- How can JavaScript save to a local file?
- Defining a HTML template to append using JQuery
- Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (
) - Remove escape characters from JSON string pulled from a database
- Parse JSON in JavaScript? [duplicate]
- How to change CSS using jQuery?
- How to properly use jsPDF library
- How do I redirect to another webpage?
- How do I redirect to another webpage?
- “SyntaxError: Unexpected token < in JSON at position 0"
- Cross-Origin Read Blocking (CORB)
- jQuery append() vs appendChild()
- How to replace innerHTML of a div using jQuery?
- SyntaxError: Unexpected token o in JSON at position 1
- Uncaught ReferenceError: $ is not defined?
- Uncaught ReferenceError: jQuery is not defined [duplicate]
- How do I check whether a checkbox is checked in jQuery?
- Error OPTIONS net::ERR_CONNECTION_REFUSED
- SyntaxError: Unexpected token o in JSON at position 1
- What is JSONP, and why was it created?
- TypeError: Converting circular structure to JSON in nodejs
- ReferenceError: $ is not defined
- Uncaught ReferenceError: jQuery is not defined [duplicate]
- What does [object Object] mean?
- Remove class using jQuery
- How do I check whether a checkbox is checked in jQuery?
- jQuery document.createElement equivalent?
- How to make history.back() without getting a warning on the browser to reload the page?
- JQuery – $ is not defined
- Cannot read property ‘push’ of undefined when combining arrays
- Use a JSON array with objects with javascript
- Toggle show/hide on click with jQuery
- convert Hsl to rgb and hex
- Array of JSON Objects
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- Chrome sendrequest error: TypeError: Converting circular structure to JSON
- JQuery – $ is not defined
- Cannot read property ‘push’ of undefined when combining arrays
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Fetch: POST JSON data
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- How to create a jQuery function (a new jQuery method or plugin)?
- jQuery: Wait/Delay 1 second without executing code
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function
- Scroll to an element with jQuery
- Uncaught SyntaxError: Unexpected token u in JSON at position 0
- Download File Using JavaScript/jQuery
- How to solve ‘Redirect has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header’?
- How to deal with net::ERR_SSL_PROTOCOL_ERROR?
- How can I scroll to an element using jQuery?
- jQuery.click() vs onClick
- jQuery setTimeout() Function [duplicate]
- jQuery Get Selected Option From Dropdown
- Disabling and enabling a html input button
- Scroll to an element with jQuery
- Download File Using JavaScript/jQuery
- Unexpected token u in JSON at position 0 (but only sometimes)
- How to read an external local JSON file in JavaScript?
- Check if checkbox is checked with jQuery
- How can I refresh a page with jQuery?
- How can I refresh a page with jQuery?
- Getting Error “Form submission canceled because the form is not connected”
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- How to add jQuery code into HTML Page
- How can I get the data-id attribute?
- document.getElementById vs jQuery $()
- How to read an external local JSON file in JavaScript?
- Check if checkbox is checked with jQuery
- How to import jquery using ES6 syntax?
- How to filter an array/object by checking multiple values
- What does jQuery.fn mean?
- Getting Error “Form submission canceled because the form is not connected”
- Is there a link to the “latest” jQuery library on Google APIs?
- What is the convention in JSON for empty vs. null?
- What is the “right” JSON date format?
- Setting “checked” for a checkbox with jQuery
- How to find the sum of an array of numbers
- What is the “right” JSON date format?
- Jquery : Refresh/Reload the page on clicking a button
- Uncaught SyntaxError: Invalid or unexpected token
- Check if element exists in jQuery
- Checking a Url in Jquery/Javascript