C# json parse string inside 2nd curly brackets {X{Y}}

I try to parse string inside 2nd curly brackets using C# / json

String looks like this:


My aim is read value of DEVX, which is 0.1346224

I've tried:

var joR = JObject.Parse(R);
string R27 = joR["R27"].ToString();

RETURNS : {"DEVX":0.1346224}}

string R27 = joR["DEVX"].ToString();


Is there way to get directly value "0.1346224" without playing with string?

Jon Skeet

Yes, absolutely - assuming you know the two names involved, you can just index twice, once to get the object for R27, then once within that object to get the value of DEVX:

using System;
using Newtonsoft.Json.Linq;

public class Test
    static void Main()
        string json = "{\"R27\":{\"DEVX\":0.1346224}}";
        var obj = JObject.Parse(json);
        double devX = (double) obj["R27"]["DEVX"];


See more on this question at Stackoverflow