Questions tagged [deserialization]

Deserialization is the process by which an object is recreated from its serialized state.

7954 questions
557
votes
19 answers

How can I deserialize JSON with C#?

I have the following code: var user = (Dictionary)serializer.DeserializeObject(responsecontent); The input in responsecontent is JSON, but it is not properly deserialized into an object. How should I properly deserialize it?
user605334
451
votes
17 answers

Convert string with commas to array

How can I convert a string to a JavaScript array? Look at the code: var string = "0,1"; var array = [string]; alert(array[0]); In this case alert shows 0,1. If it where an array, it would show 0. And if alert(array[1]) is called, it should pop-up…
Scott
  • 5,991
  • 15
  • 35
  • 42
363
votes
6 answers

.NET NewtonSoft JSON deserialize map to a different property name

I have following JSON string which is received from an external party. { "team":[ { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"home", "score":"22", …
RasikaSam
  • 5,363
  • 6
  • 28
  • 36
340
votes
12 answers

Deserializing JSON to .NET object using Newtonsoft (or LINQ to JSON maybe?)

I know there are a few posts about Newtonsoft so hopefully this isn't exactly a repeat...I'm trying to convert JSON data returned by Kazaa's API into a nice object of some kind WebClient client = new WebClient(); Stream stream =…
J Benjamin
  • 4,722
  • 6
  • 29
  • 39
336
votes
9 answers

How to implement custom JsonConverter in JSON.NET?

I am trying to extend the JSON.net example given here http://james.newtonking.com/projects/json/help/CustomCreationConverter.html I have another sub class deriving from base class/Interface public class Person { public string FirstName { get;…
Snakebyte
  • 3,735
  • 3
  • 16
  • 12
300
votes
8 answers

Deserializing a JSON into a JavaScript object

I have a string in a Java server application that is accessed using AJAX. It looks something like the following: var json = [{ "adjacencies": [ { "nodeTo": "graphnode2", "nodeFrom": "graphnode1", "data": { …
mj_
  • 6,297
  • 7
  • 40
  • 80
288
votes
4 answers

What is deserialize and serialize in JSON?

I have seen the terms "deserialize" and "serialize" with JSON. What do they mean?
254
votes
9 answers

Converting Stream to String and back

I want to serialize objects to strings, and back. We use protobuf-net to turn an object into a Stream and back, successfully. However, Stream to string and back... not so successful. After going through StreamToString and StringToStream, the new…
flipuhdelphia
  • 2,543
  • 2
  • 12
  • 5
155
votes
6 answers

Performant Entity Serialization: BSON vs MessagePack (vs JSON)

Recently I've found MessagePack, an alternative binary serialization format to Google's Protocol Buffers and JSON which also outperforms both. Also there's the BSON serialization format that is used by MongoDB for storing data. Can somebody…
Alex
  • 8,245
  • 8
  • 46
  • 55
147
votes
7 answers

Deserializing JSON data to C# using JSON.NET

I'm relatively new to working with C# and JSON data and am seeking guidance. I'm using C# 3.0, with .NET3.5SP1, and JSON.NET 3.5r6. I have a defined C# class that I need to populate from a JSON structure. However, not every JSON structure for an…
user305145
120
votes
5 answers

JSON to TypeScript class instance?

I've done quite some research, but I'm not totally satisfied with what I found. Just to be sure here's my question: What is actually the most robust and elegant automated solution for deserializing JSON to TypeScript runtime class instances? Say I…
Klaus
  • 1,201
  • 2
  • 9
  • 5
118
votes
13 answers

How to remove k__BackingField from json when Deserialize

I am getting the k_BackingField in my returned json after serializing a xml file to a .net c# object. I've added the DataContract and the DataMember attribute to the .net c# object but then I get nothing on the json, client…
114
votes
9 answers

Polymorphism with gson

I have a problem deserializing a json string with Gson. I receive an array of commands. The command can be start, stop , some other type of command. Naturally I have polymorphism, and start/stop command inherit from command. How can I serialize…
Sophie
  • 1,580
  • 3
  • 16
  • 20
100
votes
4 answers

Newtonsoft JSON Deserialize

My JSON is as follows: {"t":"1339886","a":true,"data":[],"Type":[['Ants','Biz','Tro']]} I found the Newtonsoft JSON.NET deserialize library for C#. I tried to use it as follow: object JsonDe = JsonConvert.DeserializeObject(Json); How can I access…
abc cba
  • 2,563
  • 11
  • 29
  • 50
97
votes
9 answers

Fastest way to serialize and deserialize .NET objects

I'm looking for the fastest way to serialize and deserialize .NET objects. Here is what I have so far: public class TD { public List CTs { get; set; } public List TEs { get; set; } public string Code { get; set; } public…
aron
  • 1,874
  • 5
  • 23
  • 29
1
2 3
99 100