The JSON you posted looks fine, however in your code, it is most likely not a JSON string anymore, but already a JavaScript object. This means, no more parsing is necessary.
You can test this yourself, e.g. in Chrome’s console:
new Object().toString() // "[object Object]" JSON.parse(new Object()) // Uncaught SyntaxError: Unexpected token o in JSON at position 1 JSON.parse("[object Object]") // Uncaught SyntaxError: Unexpected token o in JSON at position 1
JSON.parse()
converts the input into a string. The toString()
method of JavaScript objects by default returns [object Object]
, resulting in the observed behavior.
Try the following instead:
var newData = userData.data.userList;
Related Posts:
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- How to get all place details from a Place Details Request using Google Places API Web Service?
- What is JSONP, and why was it created?
- TypeError: Converting circular structure to JSON in nodejs
- Use a JSON array with objects with javascript
- Array of JSON Objects
- Chrome sendrequest error: TypeError: Converting circular structure to JSON
- Fetch: POST JSON data
- Uncaught SyntaxError: Unexpected token u in JSON at position 0
- Unexpected token u in JSON at position 0 (but only sometimes)
- How to read an external local JSON file in JavaScript?
- How to read an external local JSON file in JavaScript?
- What is the convention in JSON for empty vs. null?
- What is the “right” JSON date format?
- AngularJS- Login and Authentication in each route and controller
- Nested JSON objects – do I have to use arrays for everything?
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- What is the “right” JSON date format?
- TypeError: Cannot read property ‘then’ of undefined
- How to compare arrays in JavaScript?
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- jQuery AJAX cross domain
- In angularjs we are having ng-disabled directive, why ng-enabled directive is not provided by the framework as we are having ng-show and ng-hide
- Regular expression : match either of two conditions?
- Uncaught TypeError: Cannot read property ‘props’ of null
- Give a value to an ng-model=”searchText” input based on list item clicked in Angular JS
- Loading local JSON file
- TypeError: Cannot read property ‘get’ of undefined on AngularJS
- How to convert JSON object to JavaScript array?
- node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]
- Uncaught TypeError: data.push is not a function
- React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- Blocked script execution in because the document’s frame is sandboxed – Angular application
- How to convert selected HTML to Json?
- Angular JS Uncaught Error: [$injector:modulerr]
- Use of $parse in angular js
- How can I group data with an Angular filter?
- How to get JSON from URL in JavaScript?
- How do you put an image file in a json object?
- push object into array
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- JSON.parse() not working
- Disable Chrome strict MIME type checking
- Angularjs: Error: [ng:areq] Argument ‘HomeController’ is not a function, got undefined
- Refused to execute script, strict MIME type checking is enabled?
- Error: [ng:areq] from angular controller
- TypeError: res.json is not a function
- SyntaxError: expected expression, got ‘<'
- Understanding the ngRepeat ‘track by’ expression
- How to pass parameters using ui-sref in ui-router to controller
- What does ngf-select do and why is it needed for form validation?
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- Add new attribute (element) to JSON object using JavaScript
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- why angularjs ng-repeat not working
- How to display raw JSON data on a HTML page
- How to connect signalR from angularJs
- Convert array to JSON
- JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?
- How do you serve a file for download with AngularJS or Javascript?
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- How to add a button dynamically using jquery
- Using setTimeout on promise chain
- How to redirect to another page using AngularJS?
- Complex JSON nesting of objects and arrays
- How can JavaScript save to a local file?
- How to enable CORS in AngularJs
- Write / add data in JSON file using Node.js
- How do I handle newlines in JSON?
- Finding the max value of an attribute in an array of objects
- Defining a HTML template to append using JQuery
- How do I bind to list of checkbox values with AngularJS?
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- parsing JSONP $http.jsonp() response in angular.js
- AngularJS POST Fails: Response for preflight has invalid HTTP status code 404
- What is the cause for “angular is not defined”
- Unexpected token < in first line of HTML
- ngular is automatically adding ‘ng-invalid’ class on ‘required’ fields
- What are the differences between JSON and JSONP?
- Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (
) - WP Rest API – How to get featured image
- Implementing Isomorphic JavaScript (React JS) in WordPress?
- How to use wp_localize_script in custom page template?
- Dynamically insert values in a WordPress SelectControl Options field
- var is undefined in a Gutenberg block
- 404 Error Contact Form 7 on WordPress
- Base64 & JSON Encode array in PHP, use as HTML data attribute, decode and parse in JavaScript …. with proper Escaping
- AngularJS with route and JSON API
- Pass data from wordpress to javascript in JSON
- How to include a JSON file on my page?
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- how to use nimble-API and Display data?
- Remove escape characters from JSON string pulled from a database
- I would like to retrive JSON value and display it in wordpress page or widget
- Connecting a wordpress site to an AngularJS APP
- Gutenberg core/file add style support in js/ json