Is there any tool out there can convert Java's JSON to/from C#?
JSON is a data interchange format (JavaScript Object Notation) that is not tied to either Java or .NET or any specific implementation.
Are you looking for a JSON library for .NET? There are links to many libraries for different platforms and languages at the bottom of the linked page.
AFAIK Json is not server-side-language-dependent, since it applies to JavaScript, not strictly to Java or C#. Given this, a Json correctly formatted should correctly work with any parser in any server-side language. If you are searching a C# implementation for Json handling, take a look at these sources:
And to complement with Java-side tools (which are aplenty as well), I suggest having a look at Jackson JSON parser/databinder. For other suggestions there are many many SO questions, such as this one.
In .NET you can use the DataContract and DataMember attributes from the System.Runtime.Serialization to define the variables of the Json object like this
using System.Runtime.Serialization;
[DataContract]
class MyJSONObject
{
[DataMember(Name="property1")]
public int Property1
{
get;
set;
}
[DataMember(Name = "property2")]
public int Property2
{
get;
set;
}
}
Then, provided you are using .NET 3.5 or later, you can use the DataContractJsonSerializer class from the System.Runtime.Serialization.Json namespace to serialize your object to a JSON string or deserialize a JSON string to your object.