c# - Can't use JavaScriptSerializer in Windows Universal Application -
i have prototyped getting json data web service in visual studio 2017 c# console application, deserializing json data 3 strings. moved code windows 10 universal application.
the deserialization code won't compile in uwp program because type javascriptserializer not available. i'm unable add system.web.extensions system (references/assemblies/framework), getting message vs 2017, "no framework assemblies found on machine," when windows 10 solution open.
here json string:
{ "snippet":"\"special counsel ...\"", "snippetdate":"9/9/2017 12:00:00 am", "snippetsource":"the washington post" }
here code snippets compile , run on console project not windows 10 project.
using system.web.script.serialization; . . . public class newssnippet { public string snippet { get; set; } public string snippetdate { get; set; } public string snippetsource { get; set; } } . . . var serializer = new javascriptserializer(); var deserializedresult = serializer.deserialize<newssnippet>(jsonstring);
what alternatives there deserialize json string in universal windows application?
you should able add newtonsoft's json.net via nuget
var deserializedresult = jsonconvert.deserializeobject<newssnippet>(jsonstring); var source = deserializedresult.snippetsource;
Comments
Post a Comment