JSON de-serialization with MonoTouch

后端 未结 2 655
一个人的身影
一个人的身影 2021-01-05 09:17

there are various ressources on the web explaining how to serialize some C# object to a JSON string. I have been unable to get any of them to work with MonoTouch 3.2

2条回答
  •  猫巷女王i
    2021-01-05 09:47

    I don't have street cred, so I can't post a comment to the answer above..

    Just wanted to post a warning when using the System.Json.JsonObject.ToString() method. I was using this, and it seemed to generate JSON fine.. then I had a string with a return (\n) in it. It didn't escape this properly, and it ended up generating bad JSON..

    So, if you have simple JSON, it may work just fine, but if you know you may have special characters in your strings that require escaping, you should test that "ToString()" method first.

    I think the newtonsoft JSON library looks like an alternative. There is info about this over at Xamarin's site:

    https://components.xamarin.com/view/json.net

    Realize this is an awful answer, but just wanted to post the warning to users of the system json lib.

提交回复
热议问题