How can I deserialize a JSON string in Mono?

I recommend looking at ServiceStack.NET Text. It is incredibly fast compared to JSON.NET.

Examples of serializing a dictionary:

ServiceStack.NET

var jsonSerializer = new JsonSerializer<Dictionary<String, Object>>();
var result = jsonSerializer.SerializeToString(dict);

JSON.NET

var result = JsonConvert.SerializeObject(dict, Formatting.Indented);

Take a look at JSON.NET:

https://www.newtonsoft.com/json

Features:

  • Flexible JSON serializer for converting between .NET objects and JSON
  • LINQ to JSON for manually reading and writing JSON
  • High performance, faster than .NET's built-in JSON serializers
  • Write indented, easy to read JSON
  • Convert JSON to and from XML

Example to serialize and deserialize:

    using Newtonsoft.Json;
    ...

    public class Person
    {
        public string Name { get; set; }
        public DateTime Birthday { get; set; }
    }

    void PersonToJsonToPersonExample ()
    {
        var person = new Person { Name = "Bob", Birthday = new DateTime (1987, 2, 2) };

        var json = JsonConvert.SerializeObject (person);
        Console.WriteLine ("JSON representation of person: {0}", json);

        var person2 = JsonConvert.DeserializeObject<Person> (json);
        Console.WriteLine ("{0} - {1}", person2.Name, person2.Birthday);
    }

we are not utilizing json contract serializer - instead we use Json.NET. it should work with mono too.
you don't need to install the assembly, just add a reference and supply it with your final package!

EDIT:
how to add a reference? though i'm not a mono-devlop-er ... taken from here:

References -> Edit References -> .NET Assembly -> Browse to file & select it

otherwise: hey, just hit F1!

Tags:

C#

.Net

Json

Mono