datacontractjsonserialize

Serialize an object using DataContractJsonSerializer as a json array

I have a class which contains a list of items. I want to serialize an instance of this class to json using the DataContractJsonSerializer as a json array. eg. class MyClass { List<MyItem> _items; } class MyItem { public string Name {get;set;} public string Description {get;set;} } When serialized to json it should be like...

Accessing DataContractJsonSerializer<T> properties via re-factored foreach loop

I have the code below. The line string content = twitterMsg.text; is creating the error 'Use of unassigned local variable' for twitterMsg. I don't seem able to access my TwitterSearchResponse.results.text fields in my DataContractJsonSerializer<TwitterMain> collection. TwitterSearchResponse.results is an array (set of object propertie...

Way to Deserialize JSON from HttpWebResponse without 3rd party frameworks

I'm trying to keep from depending on open source or third party libraries such as Json.NET to parse incoming JSON from an HttpWebResponse. Why? Because the more reliance on open source frameworks to aid in your implementations, the more your app has to rely on those dependencies...I don't like my apps to be depenent on a lot of librari...

.NET Append JSON to a string already serialized with DataContractJsonSerializer

I am using DataContractJsonSerializer to serialize an object to json, and then returning to the client with AJAX. I now need to serialize another object to return along with it. The problem is MSs "d" that wraps around the JSON, that stops me from simply concatenating the strings into a single JSON string. json = json & """,""SecurityGr...

How to get key value pairs from DataContractJsonSerializer?

the correct format for my keyvalue pairs is { "Fields": { "key1": "value1", "key2": "value2" } } But I cannot get this out of my object using the DataContractJsonSerializer, does anyone know how. [DataContract] class Product { [DataMember] public Dictionary<string, stri...

Using Json deserializer with Silverlight 4 app

I've been using the DataContractJsonSerializer class to send data from a Silverlight 4 control to the server (currently as a serialized string via Http Post at the moment). The class in question serializes great on the silverlight / client side but deserializing back has been a problem on the server. The closest I've gotten is inclusio...

Using DataContractJsonSerializer

I am trying to host a WCF service that responds to incoming requests by providing a json output stream. I have the following type [DataContract] [KnownType(typeof(List<HubCommon>))] [KnownType(typeof(Music))] [KnownType(typeof(AppsAndPlugins))] [KnownType(typeof(Notifications))] [KnownType(typeof(Scenes))] [KnownType(typeof(Skins))] ...

Deserializing a JSON array of mixed types

Hi, I'm having trouble deserializing a JSON array of mixed types using the DataContractJsonSerializer class. I've spent a bunch of time looking for a solution to no avail, so I thought I'd go ahead and ask here. Basically, I am getting a JSON string like the one below. I'd like to get the array to deserialize into an List where positio...

Deserializing JSON 2 Dimension array of values

Hi all, I've got a 2 dimensional of values in JSON format: [[57, 2], [57, 2], [58, 2], [55, 2], [60, 2], [54, 1], [59, 11]] Each of the pairs actually contains a pair of unrelated readings, and there is one pair for each minute. So in the first min, reading 1 is 57 and reading 2 is 2 and in the second minute, the readings are the same...