Json

How can I create a JSON payload to upload to my Web server (I need to call a Web Api) from my Cerbuino?

System.Runtime.Serialization.Json?
the old FastloadMedia.NETMF.Http that I did use on my Panda?
Any GHI lib available somewhere in code base?

Thanks

@ baz - there is a JSON project in the codeshare section https://www.ghielectronics.com/community/codeshare/entry/282 will that do what you need??

This is FastloadMedia.NETMF.Http I’ve used on Panda.

I don’t know if I may use this (old) custom code, or if there is some integrated (more powerful) features in 2013 platforms that I can use…

This should still work, i havent used JSON myself but im sure if there is anything newer or better the US guys will know.

This depends on how you want to serialize, but its also quite simple to manually convert a class to JSON. Say your class contained two integers and a string.

public class JSONData 
{
    public int a = 0;
    public int b = 5;
    public string str = "Heres my string";
}

You could simply inject the data into a string, so that the formatting looks like this:

{
    "data": [
        {
            "a": "0",
            "b": "5",
            "str": "Heresmystring"
        }
    ]
}

This will create a Javascript array object named data, with fields ‘a’,‘b’, and ‘str’. A great validation tool can be found at http://jsonlint.com/