Search code examples
c#jsonstringvisual-studio-2010.net-micro-framework

How to create a JSON string in c#/NETMF?


At present, I am using a string value MyFinalJSON to create a string.

the like of MyFinalJSON += "\"Name\":\"" + myNameString +"\"";

This seems a very long winded/error prone way of writing in JSON format.

Is there a better/more appropriate way of creating JSON strings? Especially when the JSON string can get very long.

EDIT Oh sorry I forgot to mention I'm using the NetMF framework, and so there isn't a namespace for system.web..., amongst many others

Any advice much appreciated.


Solution

  • Use json.netmf or download and extract the file from here

    Github: https://github.com/mweimer/Json.NetMF

    From the documentation, here is the usage.

    string json = JsonSerializer.SerializeObject(o, DateTimeFormat.Default);