90 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 42
4 star 14
3 star 19
2 star 9
1 star 6
Compatible with
  • Android
  • iOS
  • Windows

Json.NET 7.0.1

Xamarin Inc

Json.NET is a popular high-performance JSON framework for .NET

Json.NET is a high-performance JSON framework.

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

For simple conversions to and from JSON strings and .NET objects, JsonConvert provides the SerializeObject and DeserializeObject methods.

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);
}

For dealing with JSON data in more direct form, without mapping them to C# classes, use LINQ to JSON:

using Newtonsoft.Json.Linq;
...

void LinqExample ()
{
    string json = @"{ Name: 'Bob', HairColor: 'Brown' }";
    var bob = JObject.Parse (json);

    Console.WriteLine ("{0} with {1} hair", bob["Name"], bob["HairColor"]);
}

Release Notes

7.0.1

  • Updated to the latest NuGet

6.0.8.1

  • Fixed iOS NuGet dependency

6.0.8.0

  • Updated to v6.0.8
  • Now includes Json.Net as a NuGet dependency
  • iOS Unified API Compatible
Write a Review

33 reviews

abdellah amri

how can use json.net to retrieve date from google blogspot json feeds

Posted on: February 25, 2016 / Version: 7.0.1
Sam

This version can't support the project that targets 'MonoAndroid,Version=v4.4',how to do?

Posted on: January 15, 2016 / Version: 7.0.1
iturralde pablo

Im using the version 8.0.2,

I'm having a lot of issues when I set in my project link all assemblies. it gives me this exception.

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The non-generic method `Newtonsoft.Json.Linq.JToken.ToObject(System.Type)' cannot be used with the type arguments This is my code: var raw = JsonConvert.DeserializeObject(json); var data = raw ["data"]; List offers = data.ToObject> (); // exception return offers;

Posted on: January 14, 2016 / Version: 7.0.1
Alexey Strakh rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

@Tim Ricciardi I have the same issue with android and release. And actually it is enough to exclude just System.Core lib from being linked.

Posted on: June 11, 2015 / Version: 6.0.8.1
Jason C. HandUber rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Version 6.0.8 works like a charm for me in Xamarin Studio in a PCL project

Posted on: April 18, 2015 / Version: 6.0.8.1
HDV Game Studio

I only use version 4.5.11.1

Posted on: March 12, 2015 / Version: 6.0.8.1
Chai Botta
Posted on: February 12, 2015 / Version: 6.0.8.1
Dragos rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Please add a dll

Posted on: February 11, 2015 / Version: 6.0.8.1
Marco Guilmette rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Error on install in Xamarin.IOS.

I looked to the json.net-6.0.8.0 folder in my project components and there is no dll.

Posted on: January 21, 2015 / Version: 6.0.8.0
Andrey Bespamyatnov rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

On Xamarin.IOS, Error on install

Posted on: January 21, 2015 / Version: 6.0.8.0
xamarin_cd rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

don't have dll in 6.0.8

Posted on: January 20, 2015 / Version: 6.0.8.0
Tim Ricciardi rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

We were getting a System.Runtime.Serialization.dll not found when trying to deploy our Xamarin Android app in Release Mode. We fixed it by setting the linker to Link SDK assemblies only and to ignore assemblies: System.Core;System.Runtime.Serialization

It only added another meg to the file size

Posted on: November 14, 2014 / Version: 4.5.11.1
Gustavo Machado

How can I do to send json to server, can someone give me one example?

Posted on: November 11, 2014 / Version: 4.5.11.1
Hao Li rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Great work.

As to support iPhone6, need to support unified API to debug on simulator, can you get the component to support unified API ?

Posted on: September 16, 2014 / Version: 4.5.11
lincolnx

asdfasdfsdfsdf

Posted on: August 23, 2014 / Version: 4.5.11
Ullas Krishnan

This component was working fine but when I create Android package it is no exported to the device and not working fine. The program cannot find the dll. I am using Xamarin for Android Business version ... Is this the problem with xamarin license ?

Posted on: July 18, 2014 / Version: 4.5.11
Jue Wang rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I want to translate a string to a JsonArray, the string was write by Json format. I can't find a way to do that.

Posted on: July 14, 2014 / Version: 4.5.11
Magnus Ahlin rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Mandatory!

Posted on: July 7, 2014 / Version: 4.5.11
TianYu Liu rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

is that updated to 6.0?

Posted on: February 14, 2014 / Version: 4.5.11
Raul Rodriguez rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Hello there, using the Json.net downloaded from NuGet isn't working for me.

I have download the dll's and Add the Reference manually. No luck. I have create a folder in the Core project, add the dll, then reference to there. No luck.

Always get the same exception: Could not load file or assembly 'System.Dynamic.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Last thing I wanted to try are the libraries from this component, but I've two dll's (iOS, Android) how should I use them if I want to deserialize in the Core project.

If you have any advice, solution post it here in the blog: http://forums.xamarin.com/discussion/9011/system-typeloadexception/p1 Thanks!

Posted on: December 17, 2013 / Version: 4.5.11
Bo Kingo Madsen rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I don't know if it's a limitation of the linker, but I couldn't make it work, if I referenced it from a class library, because the linker didn't embed the newstonsoft.json.dll file in the deployed solution, giving a "file not found", when using json.net. My solution was to add the newtonsoft.json.dll file to the class library as Content, and reference it "normally" in the Component folder

Posted on: December 10, 2013 / Version: 4.5.11
Andrei Nitescu

Json.NET has now PCL version

Get the latest one from http://json.codeplex.com/releases/ and get the .dll from \Bin\Portable40 or \Bin\Bin\Portable depending on the portable platform you target

Posted on: September 18, 2013 / Version: 4.5.11
An Nguyen

I dont know why it not work on new version of xamarin .

JsonConvert.DeserializeObject

with string { success: false, errorCode: "404", errorMessage: "Organization is empty" }

Posted on: September 10, 2013 / Version: 4.5.11
Yuri Shteinman rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Great library. Tested on Android

Posted on: September 5, 2013 / Version: 4.5.11
Pierce Boggan rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Fantastic! Easily drops in and replaces the old Github version from Andrew Young I was using. Would love to see "async/await" support (which is in the original version on Github).

PRO TIP: For generating your model classes, check out: http://json2csharp.com/

Posted on: August 16, 2013 / Version: 4.5.11
Christer Nordvik rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Works great but somewhere it should be mentioned that you have to add [Preserve] on your empty constructors in release-mode and also [Preserve(AllMembers=true)] to the class. At least I learned this the hard way as we released our app without testing it in release-mode and that didn't go very well. Seems like the compiler tries to be clever and removes the constructor. Just added [Preserve] and everything is jolly good again.

Posted on: July 23, 2013 / Version: 4.5.11
James Montemagno rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Works as expected. Does it's job great. Using in both iOS and Android.

Posted on: June 23, 2013 / Version: 4.5.11
Davut Gürbüz rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I bought iOS and Android's INDIE version. It works perfectly for iOS but for Android it says System.Runtime.Serialization is available for Business and Enterprise versions. There must be something wrong, it is a very base lib. At this discussion http://monogame.codeplex.com/discussions/435092 the final post from "tairon" says System.Runtime.Serialization included Indie. But why can't I build it using my INDIE ?

Posted on: March 23, 2013 / Version: 4.5.11
S. J. A. van Rooij rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I was using the github version from Andrew Young, but i replaced it with this one very easy.

Just added this component and removed the old one from the references.

Posted on: March 17, 2013 / Version: 4.5.11
Nick

I get the same error as John. System.IO.FileNotFoundException.

Posted on: March 17, 2013 / Version: 4.5.11
Michael Thwaite rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Works sublimely. I started using this component before I really understood what I was doing, now I understand more and, how this component tolerated the ridiculous errors I was making!

Posted on: March 6, 2013 / Version: 4.5.11
Mark Trinder rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Not having any issues with this component. I was using the GitHub version.

Added the component to my project via the Store and then removed the GitHub assembly reference. No code changes, rebuild, all good.

Posted on: March 5, 2013 / Version: 4.5.11
John Waters rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I get a warning at compile time about it using a newer version of .NET than MonoTouch supports. And then at runtime it can't find Newtonsof.Json.MonoTouch?

Posted on: March 1, 2013 / Version: 4.5.11