How do I de/serialize JSON in WinRT?

前端 未结 3 1212
灰色年华
灰色年华 2020-12-08 05:10

How do I take an object and convert it to a JSON string and then back into that object from a string, specifically, in WinRT for my Windows 8 Metro application?

3条回答
  •  难免孤独
    2020-12-08 05:51

    OP asked for an answer that pertained to metro apps on Windows 8, but this question comes up when doing a basic search for serializing/de-serializing jsons for WinRT, so I'm adding this answer for those who are looking for a more modern approach.

    Modern WinRT has built-in handlers for this challenge, so no need to use JSON.net

    Use JsonObject from Windows.Data.Json

    For serializing use Parse or TryParse.

    For de-serializing but still in JSON format, use Stringify.

提交回复
热议问题