0

Can any make this json correct, I am inserting json in JSON online Validator

Getting error that json is not valid, what is error in this json, and how can I make it correct, please don't give links of other tutorials, Thanks

{
    mothmap: {
        value: [{
            longitude: -0.13025200000004133,
            latitude: 51.4596619
        }, {
            longitude: -2.707384100000013,
            latitude: 53.7613383
        }]
    }
 }

7 Answers 7

5

You need double quotes around your strings. This passes the validator:

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

longitude: "-2.707384100000013", I did like this, but no use, it is still not validate
I have upvoted you, will accept you answer, after 8 mints, thank you sir :-)
@Veer The quotes go around the string (i.e., "longitude"), not around the number (unless you want it to be a string too).
2
{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}

Strings need to be in quotes.

Comments

1

If you're using a validator, why didn't you bother to look at the output!

It says:

Parse error on line 1:
{    mothmap: {        
-----^ Expecting 'STRING', '}'

EXPECTING STRING means its looking for a string..........

put all the bits BEFORE the :s inside double quotes...

eg: { "mothmap": { .....

Comments

1

JSONLint requires properties to be written in quotes:

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200000004133,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.707384100000013,
                "latitude": 53.7613383
            }
        ]
    }
}

However, yours was perfectly valid. JSONLint just complains too much.

4 Comments

"However, yours was perfectly valid." [Citation needed]
I just looked into the detailed documentation of JSON and the official Javascript Object notation. I was wrong, the keys of objects seem to need quotes after all. But it still should work, so it's not invalid, is it?
If it violates the spec, it's not valid. And since I expect most parsers to be written based on the spec, I guess it won't work without quotes in most of them.
I am using it in iOS, but the same url is being used for website, and in php it is working fine and valid, but here it is creating issue for me in iOS
0

A valid json has its key quoted, just like string values.

1 Comment

longitude: "-2.707384100000013", I did like this, but no use , can you edit my json, and give me answer.
0

All strings must be in quotes, key's included.

Comments

0

Like this :

{
    "mothmap": {
        "value": [
            {
                "longitude": -0.13025200033,
                "latitude": 51.4596619
            },
            {
                "longitude": -2.70738400013,
                "latitude": 53.7613383
            }
        ]
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.