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
- How do I redirect to another webpage?
- jQuery append() vs appendChild()
- What is JSONP, and why was it created?
- ReferenceError: $ is not defined
- Cannot read property ‘push’ of undefined when combining arrays
- How to deal with net::ERR_SSL_PROTOCOL_ERROR?
- Scroll to an element with jQuery
- Download File Using JavaScript/jQuery
- How to read an external local JSON file in JavaScript?
- SyntaxError: Unexpected token o in JSON at position 1
- Check if checkbox is checked with jQuery
- Getting Error “Form submission canceled because the form is not connected”
- What is the “right” JSON date format?
- Check if element exists in jQuery
- Checking a Url in Jquery/Javascript
- Change Background color (css property) using Jquery
- jQuery get textarea text
- Get class name using jQuery
- Uncaught TypeError: $.post is not a function
- jQuery animate backgroundColor
- Left() function in Javascript or jQuery
- XML Parsing Error: no root element found Location in Console FF
- How to Open New window on every Click
- Jquery Ajax Call, doesn’t call Success or Error
- How to create a stopwatch using JavaScript?
- Convert UTC date time to local date time
- With jQuery, how do I capitalize the first letter of a text field while the user is still editing that field?
- Obtain form input fields using jQuery?
- How to move an element after another element using JS or jquery?
- Why is the jquery script not working?
- JQuery Datatables : Cannot read property ‘aDataSort’ of undefined
- Javascript/Jquery Convert string to array
- JSON.parse() not working
- jQuery make global variable
- Refused to execute script, strict MIME type checking is enabled?
- How to send email by using javascript or jquery
- How to get current date in jQuery?
- Print the contents of a DIV
- How to Scroll Down – JQuery
- Embedding instagram webpage inside an iframe
- Do something if screen width is less than 960 px
- Uncaught TypeError: Cannot read property ‘toUpperCase’ of undefined
- jQuery remove options from select
- Load Image from javascript
- is there something like isset of php in javascript/jQuery?
- jQuery – Dynamically Create Button and Attach Event Handler
- Highlight a word with jQuery
- Error: TypeError: $(…).dialog is not a function
- getContext is not a function
- How to change the text of a label?
- How to check ‘undefined’ value in jQuery
- Data column(s) for axis #0 cannot be of type string in google chart dashboard [duplicate]
- navigator.geolocation.getCurrentPosition sometimes works sometimes doesn’t
- Jquery Value match Regex
- Using “×” word in html changes to ×
- How to check if the URL contains a given string?
- How should I initialize jQuery?
- How to reload page every 5 seconds?
- How do I handle newlines in JSON?
- Fire oninput event with jQuery
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- How to scroll to top of page with JavaScript/jQuery?
- How to set “style=display:none;” using jQuery’s attr method?
- Change the selected value of a drop-down list with jQuery
- How to dequeue a script?
- How to use wp_localize_script in custom page template?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- Dynamically insert values in a WordPress SelectControl Options field
- AngularJS with route and JSON API
- List of JS Events for Widgets?
- JQuery not loading
- Uncaught ReferenceError: jQuery is not defined – although jQuery is loaded [closed]
- Uncaught TypeError: jQuery(…).slider is not a function
- Parse wordpress blog data using json api and ajax
- Putting custom html/js page into Elementor as it’s own block
- “jQuery Not Defined” Error When Connecting to PayPal
- Fade-in Fade-out doesn’t work in WordPress
- Open image gallery on link click
- Connecting a wordpress site to an AngularJS APP
- Uncaught ReferenceError: tippy is not defined