Click here to Skip to main content
11,933,213 members (66,528 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript Mobile Android JSON , +
Hello, I'm having problems while getting JSPN from PHP, shown below:

        "vehicleId": "1",
        "status": "Running",
        "position": "x",
        "battery": "25",
        "distanceTravelled": "123",
        "destination": "y",
        "freeSeats": "2",
        "speed": "32"

But, my new version of my code it is comes like that (without quotes in number values) and it gives a parse Json error and it doen't shown anything.
        "vehicleId": 1,
        "status": "Running",
        "position": "x",
        "battery": 25,
        "distanceTravelled": 123,
        "destination": "y",
        "freeSeats": 2,
        "speed": 32

I checked the format at and it is valid. The error in log in Eclipse is:

05-09 21:37:25.536: E/Web Console(336): SyntaxError: Unable to parse JSON string at file:///android_asset/www/MobileMan.js:37

        35  xmlhttp.send();
        36  var json = xmlhttp.responseText; 
        37  obj = JSON.parse(json);

I also tried the Javascript code in my computer on Chrome and everything works fine. I couldn't resolve the problem. Thanks for your answers.
Posted 10-May-13 3:43am
Edited 10-May-13 4:14am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try by removing double quote

"vehicleId" as vehicleId

        vehicleId: "1",
        status: "Running",
        position: "x",
        battery: "25",
        distanceTravelled: "123",
        destination: "y",
        freeSeats: "2",
        speed: "32"
fatihkok 10-May-13 9:20am
hello @Prasad C.M, I' m Sorry I just forgot to add " part while I'm writing the question in here, I editted my question. My original code it is ok but it doesn't work again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100