Quote problem in JSON

Asked

Viewed 824 times

-1

I’m running an application that reads a JSON result. I recently changed my server and noticed that the application stopped working. After several tests I found that my new server put quotes in some values, disabling the application.

To illustrate, I have the two results in JSON, one that works and one that doesn’t:

JSON - Works in the application [{"id":1,"start":"1413972000000","end":"1413979200000","title":"9,10,11,12","scheduling status":1,"userid":1,"name":"Test"}]

against:

JSON - Does not work in the application [{"id":"1","start":"1413972000000","end":"1413979200000","title":"9,10,11,12","scheduling"}]

I noticed the difference is only because of the quotation marks. Is there any way to standardize this?

  • 2

    How are you generating JSON? In fact, literal numbers are valid, the quotes around them are unnecessary.

  • 1

    What language are you using and in what code? Both of the examples you put up are valid: http://jsonlint.com/

  • I’m using Laravel to generate Json. The strange thing is that on one server it generates with quotation marks and on another it generates without quotation marks. The command to generate JSON is the same. As described here: http://laravel.com/docs/4.2/responses#special-Responses

1 answer

0

I solved the problem by installing php-mysqlnd:

sudo apt-get install php5-mysqlnd
sudo /etc/init.d/apache2 restart
  • 2

    How installing a mysql driver solved a JSON-generating problem?!

  • I think the problem is not in your json but in the mode that uses the variables sent by the object in your application.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.