2

I am new to JSON parsing, I know how to parse XML, but JSON seems compleatly different and confusing. I have this Array here:

{
    "domain": "Lorem Ipsum",
    "next_page_id": null,
    "url": "Lorem Ipsum",
    "short_url": "Lorem Ipsum",
    "author": "Lorem Ipsum",
    "excerpt": "Lorem Ipsum",
    "direction": "Lorem Ipsum",
    "word_count": 0,
    "total_pages": 0,
    "content": "Lorem Ipsum",
    "date_published": "2012-10-06 17:39:13",
    "dek": "Lorem Ipsum",
    "lead_image_url": "Lorem Ipsum",
    "title": "Lorem Ipsum",
    "rendered_pages": 1
}

I never used JSON before, but I always tought a JSON array would have a name. But this does not have one, so I can't do this:

JSONArray jArray = jObject.getJSONArray("ARRAYNAME");

Can somebody help me parsing this? thanks :)

2 Answers 2

4

This isn't a JSON Array. This is a JSON Object. Json array is represented by [] You can access these elements like so

String url = jObject.getString("url");

An array, for example would look like this:

{
    "domain": "Lorem Ipsum",
    "next_page_id": null,
    "url": "Lorem Ipsum",
    "array":
        [
            "element1",
            "element2"
        ]
}
Sign up to request clarification or add additional context in comments.

Comments

2

This is not array.Array contains elements of same type. Array is in []. {} is object. [{},{}] 2 objects in array
Checkout this tutorial: http://www.vogella.com/articles/AndroidJSON/article.html

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.