1
[
    {
        votes: "3449",
        title: "The Martian | Official Trailer [HD] | 20th Century FOX",
        post_url: "https://www.youtube.com/watch?v=Ue4PCI0NamI",
        inner_url: "https://www.reddit.com/r/movies/comments/390vcp/the_martian_official_trailer_hd_20th_century_fox/"
    },
    {
        votes: "4582",
        title: "The Easter Island heads have detailed bodies",
        post_url: "http://imgur.com/a/vDFzS",
        inner_url: "https://www.reddit.com/r/pics/comments/390cfz/the_easter_island_heads_have_detailed_bodies/"
    }
]

There's a problem in line 2, but I don't see anything wrong with my json above.

1 Answer 1

3

You can check a JSON using tools like http://jsonlint.com/.

In your case, the problem is that you are not putting your key names in quotes. Unlike Javascript, JSON requires it (and unlike JavaScript, JSON only allows double quotes around keys and strings, not single quotes).

Your JSON would look like this:

[
    {
        "votes": "3449",
        "title": "The Martian | Official Trailer [HD] | 20th Century FOX",
        "post_url": "https://www.youtube.com/watch?v=Ue4PCI0NamI",
        "inner_url": "https://www.reddit.com/r/movies/comments/390vcp/the_martian_official_trailer_hd_20th_century_fox/"
    },
    {
        "votes": "4582",
        "title": "The Easter Island heads have detailed bodies",
        "post_url": "http://imgur.com/a/vDFzS",
        "inner_url": "https://www.reddit.com/r/pics/comments/390cfz/the_easter_island_heads_have_detailed_bodies/"
    }
]
Sign up to request clarification or add additional context in comments.

1 Comment

@ Elton: You might also consider putting your non-string values, like 3449, not in quotes so they are transferred as numbers, not strings.

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.