get field out of the first json, {"in":[{"field":["resourcefield"]},23]} in csharp

You can access the field property inside the first object in using the following code:

main.cs
using System;
using Newtonsoft.Json.Linq;

class Program 
{
    static void Main(string[] args)
    {
        string json = @"{""in"":[{""field"":[""resourcefield""]},23]}";
        JObject jObject = JObject.Parse(json);
        var field = (string)jObject["in"][0]["field"][0];
        Console.WriteLine(field);
    }
}
321 chars
14 lines

This will output "resourcefield". Just replace the json variable with the JSON string you want to parse.

related categories

gistlibby LogSnag