Last post Jul 28, 2008 12:10 PM by Gremo
Jul 24, 2008 12:30 AM|Gremo|LINK
I have to parse a JSON response from a httprequest. I already have downloaded JSON.NET API (http://james.newtonking.com/pages/json-net.aspx) but i don't understand how to use it. That is, i cannot
deserialize my Json text to any object - i don't know its type!. I Have to read and output some values. I'm using JsonTextReader, however i cannot get any field/value (JsonTextReader.read never execute).
Can anyone point me to the right direction? Thanks a LOT!
Jul 24, 2008 06:33 AM|siva_sm|LINK
You should know the .NET type from which the JSON string was created or at least the compatible .NET type. Or you should deserialize the JSON string into generic System.Object. There are also examples in the JSON.NET documentation (http://james.newtonking.com/projects/json/help/).
Jul 28, 2008 12:10 PM|Gremo|LINK
Solved! Using JSON.NET give an exception if you try to convert to an xml object (because json response do not have a root). I'm using native .net classes in this way:
Protected Function GetXDocumentFromJSON(ByVal jsonStream As Stream) As XDocument
Dim doc As New XmlDocument
' Crea il JsonReader dal ResponseStream
Dim xr As XmlDictionaryReader = _