1

I deserialize JSON with Newtonsoft JSON DLL. I have next JSON answer

string answer = getjsonnanswer(url);
JObject a = JObject.Parse(answer);

How can I refer to a, that get 615 - Its value of variable in JSON answer, but it hasn't got a name.

{
    "response": [615, 
    {
        "body": "Привет) как жизнь?",
        "title": "Re(2): ...",     
        "date": 1268238828,
        "uid": 10024748,
        "mid": 11056,
        "read_state": 0,
        "out":0
    }, 
    {
        "body": "Жду :)",
        "title": "Re(23): ...",
        "date": 1268238448, 
        "uid": 27495120, 
        "mid": 11045,
        "read_state": 1,
        "out":1
    }]
}
0

2 Answers 2

1

You just need to add the indexer to get the first item from the "response" array:

JObject a = JObject.Parse(answer);

var val = a["response"][0];
Sign up to request clarification or add additional context in comments.

Comments

0
    JObject a = JObject.Parse(answer);


JsonObject a = new JsonObject(answer);
JsonArray ss = (JsonArray)a["response"];
var result = ss[0];

3 Comments

and how to find the object with a value of 615?
can you give me a exact jsonstring ?
@anant-dabhi{"response":[615,{"body":"Привет) как жизнь?","title":"Re(2): ...", "date":1268238828,"uid":10024748,"mid":11056,"read_state":0,"out":0}, {"body":"Жду :)","title":"Re(23): ...","date":1268238448,"uid":27495120, "mid":11045,"read_state":1,"out":1}]}

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.