Uncaught SyntaxError Unexpected end of JSON input at JSON parse anonymous

0 votes

I was trying to change a string to a JSON object using JSON.parse() and ended up getting this error:

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () at Object.success (dashboard.js:22) at fire (jquery-3.3.1.js:3268) at Object.fireWith [as resolveWith] (jquery-3.3.1.js:3398) at done (jquery-3.3.1.js:9305) at XMLHttpRequest. (jquery-3.3.1.js:9548)

I am using oracle jet and this is my code:

function DashboardViewModel() {

   var self = this;

    self.lineTypeValue = ko.observable('curved');

    var scatterSeries = []; 

    

    $.getJSON( "http://localhost:8080/points", function (data) {

               console.info(data);

               var ch = '{"name":"graphe1","items":'+JSON.stringify(data.results[1])+ '}';

               console.info(ch);

               console.info(JSON.parse(scatterSeries));

               scatterSeries.push(JSON.parse(ch));

               

        });

    

    

    /* chart data */

    

    this.scatterSeriesValue = ko.observableArray(scatterSeries);

    

    self.lineTypeOptions = [

        {id: 'straight', label: 'straight'},

        {id: 'curved', label: 'curved'},

        {id: 'stepped', label: 'stepped'},

        {id: 'segmented', label: 'segmented'},

        {id: 'none', label: 'none'}

    ];

  

  

}

I want the variable to scatter series to hold in a table like this one:

[ {  

  name:"graphe1",

  items:[  

     {  

        x:8,

        y:2

     },

     {  

        x:15,

        y:15

     },

     {  

        x:25,

        y:26

     },

     {  

        x:33,

        y:22

     },

     {  

        x:36,

        y:40

     }

  ]},]

Can someone help me with this?

May 9, 2022 in Java-Script by Kichu
• 19,040 points
6,843 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java-Script

0 votes
1 answer

Error:Uncaught SyntaxError: Unexpected token

Hello @kartik, Using the jQuery command getJSON and ...READ MORE

answered Oct 9, 2020 in Java-Script by Niroj
• 82,840 points
3,788 views
0 votes
1 answer

How can we parse JSON using Node.js?

Hello @kartik, You can simply use JSON.parse. The definition of ...READ MORE

answered Apr 24, 2020 in Java-Script by Niroj
• 82,840 points
815 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'setState' of undefined

Hello kartik, You dont have to bind anything, ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,840 points
827 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'indexOf' of undefined

Hello @kartik, First of all, you don't need ...READ MORE

answered Jun 2, 2020 in Java-Script by Niroj
• 82,840 points
19,538 views
0 votes
3 answers
0 votes
1 answer

Error:Parsing JSON giving “unexpected token o” error

Hello @kartik, Your data is already an object. ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,840 points
3,349 views
0 votes
1 answer

How to Parse values from a JSON file?

import json from pprint import pprint with open('data.json') as ...READ MORE

answered Oct 15, 2018 in Python by Priyaj
• 58,060 points
1,983 views
0 votes
1 answer

AWS Lambda : JSON object undefined

Change event.TagData.Time; To event.TagData[0].Time; This sh ...READ MORE

answered Jan 25, 2019 in IoT (Internet of Things) by Shubham
• 13,490 points
2,279 views
0 votes
1 answer

PHP __PHP_Incomplete_Class Object with my $_SESSION data

Hello @kartik, You just have to include the safestring.class.php before ...READ MORE

answered Nov 23, 2020 in PHP by Niroj
• 82,840 points
2,541 views
0 votes
1 answer

Why can't Python parse this JSON data?

Your data is not a valid JSON format. You ...READ MORE

answered Dec 20, 2020 in Python by Reshma
8,927 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP