0

In this thread: How to convert XML to JSON using C#/LINQ? i found the code for Converting XML to Json. I tried to implement this to Windows 8 but i have a Problem that the:

 JavaScriptSerializer

doesn't exist in Windows 8. Does any one know the assembly for the JavaScriptSerializer?

 var json = new JavaScriptSerializer().Serialize(dic);
Community
  • 1
  • 1
MrTouch
  • 654
  • 2
  • 12
  • 28
  • try `JSerialize` found [here](http://www.codeproject.com/Articles/13705/JavaScript-Serializer) – Harry89pl Sep 04 '12 at 12:45
  • 1
    try 'DataContractJsonSerializer' as it's part of the WinRT framework, or JSON.Net @ http://json.codeplex.com/ – leon.io Sep 04 '12 at 12:54
  • @leon DataContractJsonSerializer was found under System.Runtime.Serialization.Json; But i can't find the method for serializing... can you answer the question and if it works i can give you the Reputation. – MrTouch Sep 04 '12 at 13:28

2 Answers2

1

System.Web.Scripting.Serialization.JavaScriptSerializer

Requires System.Web.Extensions.dll as a reference.

Edit: If you're constrained to WinRT, check out http://json.codeplex.com/

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • Indeed it isn't (really you should have specified WinRT in your original question :P) - I don't know if JSON.Net (http://json.codeplex.com/) works in WinRT but it's worth looking at. – PhonicUK Sep 04 '12 at 14:04
  • i thought it's clear because of .net-4.5 sorry for that mistake i'll change it :) – MrTouch Sep 04 '12 at 14:05
  • .net 4.5 doesn't necessarily mean WinRT, you can build WPF/Winforms/ASP.Net that use .Net 4.5 and aren't constrained to WinRT. – PhonicUK Sep 04 '12 at 14:06
  • this worked for implementing even if i have another Problem coming up with this solution... – MrTouch Sep 04 '12 at 15:11
0

Have you had a look at the

JSonSerialiserHelper

For example:

string objectText = GetJSONObj();
MyJsonObj myJsonObj = JSonSerialiserHelper.Deserialize<MyJsonObj>(objectText);
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269