Windows Phone 8 JSON

前端 未结 5 1146
轮回少年
轮回少年 2020-12-10 16:56

I am starting the development on windows phone 8, the famous JSON.NET does not support windows phone 8 yet, is there any other library which can be used for this purpose?

相关标签:
5条回答
  • 2020-12-10 17:06

    The JSON.NET codeplex site says that WP8 is supported.

    Update: The JSON.NET NuGet package should just work with a Windows Phone 8.0 project. Adding it in VS2012 NuGet manager pulls in the WP7 version of JSON.NET. (packages\Newtonsoft.Json.4.5.10\lib\sl3-wp\Newtonsoft.Json.dll)

    JSON.NET is now also available as a Portable Class Library which you can consume from WP8 (available in NuGet or in source form).

    0 讨论(0)
  • 2020-12-10 17:15

    I was having this issue. I was able to compile the source for Windows Phone 8 instead of Windows 7.1 and it worked. NuGet would not work for me.

    Here is how I did it:

    1. Open up solution JsonXXrXX.zip\Source\Src\Newtonsoft.JSON.WindowsPhone.sln
    2. Go to properties for Newtonsoft.Json.WindowsPhone Project(Right click on the project then properties)
    3. For the dropdown of "Target Windows Phone OS Version" select Windows 8.X
    4. Compile.
    5. Grab the DLL, PDB, and XML from the output directory
    6. Add Reference to the DLL file in your Windows Phone 8 Project

    Thats it. I can't vouch that it works 100% or that you'll be able to submit your app. But it should hold you over until there is official support.

    0 讨论(0)
  • 2020-12-10 17:19

    Had the exact same problem - turns out I didn't have the newest version of NuGet.

    To upgrade, click tools -> extensions and updates and then click the Updates-tab. Update everything, restart the program and try again. :-)

    0 讨论(0)
  • 2020-12-10 17:26

    If you don't wanna make too fancy stuff (or need dictionary) suppport, you can also just use the built-in DataContractJsonSerializer (http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx)

    Btw: At least in https://json.codeplex.com/discussions/401305 some people report that the WP7.1 dll works for them, using this file: "Newtonsoft.Json.4.5.7\lib\sl4-windowsphone71\Newtonsoft.Json.dll".

    0 讨论(0)
  • 2020-12-10 17:28

    For complex json you might find this website helpful: http://json2csharp.com/#.

    0 讨论(0)
提交回复
热议问题