0

I have this Json structure:

{
  "rc": 1,
  "msg": 
  [
    {
      "msgId": "6661",
      "msgTxt": "Invalid Token"
    }
  ]
}

How can I get the 6661 Value? I've tried lots of paths, but it seems those two square brackets are making my day hard

Thanks

Richard
  • 106,783
  • 21
  • 203
  • 265
F.Rocco
  • 21
  • 5

2 Answers2

1

Assuming jdoc is your parsed document, then:

var res = jdoc["msg"][0]["msgId"];

should do it (but real code should handle errors as well).

Richard
  • 106,783
  • 21
  • 203
  • 265
0

Using JObject parser, you could use :

var obj = JObject.Parse(yourObjectJson);
var value = obj["msg"][0]["msgId"];
GGO
  • 2,678
  • 4
  • 20
  • 42