Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm having problems while getting JSON from PHP. The code in below is works:

[{
        "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 jsonlint.com 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

    34  xmlhttp.open("GET",url,false);
    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.

share|improve this question
json.parser.online.fr SyntaxError: Unexpected token v ... – Selvin 7 hours ago
1  
You have a typo in the question where you're missing a ". This must not be in your actual code since you said it passes jsonlint – squint 7 hours ago
vehicleId": 1 is missing a start ". Make sure that's just a copy paste error. – alex23 7 hours ago
quote is missing for vehileId tag. It should be "vehicleId" instead of vehicleId" – Vijay Patel 7 hours ago
@squint I'm sorry I just forgot " part while asking question, and it is still doesn't work – Fatih 7 hours ago
show 3 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.