Deserialization is the process by which an object is recreated from its serialized state.
Questions tagged [deserialization]
7954 questions
52
votes
1 answer
Convert an int to bool with Json.Net
I am calling a webservice and the returned data for a bool field is either 0 or 1 however with my model I am using a System.Bool
With Json.Net is it possible to cast the 0/1 into a bool for my model?
Currently I am getting an…

Diver Dan
- 9,953
- 22
- 95
- 166
50
votes
1 answer
Jackson deserialize extra fields as Map
I'm looking to deserialize any unknown fields in a JSON object as entries in a Map which is a member of a POJO.
For example, here is the JSON:
{
"knownField" : 5,
"unknownField1" : "926f7c2f-1ae2-426b-9f36-4ba042334b68",
"unknownField2" :…

kag0
- 5,624
- 7
- 34
- 67
48
votes
4 answers
Jackson JSON library: how to instantiate a class that contains abstract fields
I want to convert a JSON string into java object, but the class of this object contains abstract fields, which Jackson can't instantiate, and doesn't produce the object. What is the easiest way to tell it about some default implementation of an…

Marcin
- 825
- 2
- 8
- 12
48
votes
6 answers
How to serialize & deserialize JavaScript objects?
I need to serialize and deserialize JavaScript objects to store them in a DB.
Note that these objects contain functions, so I can't store them as JSON, so I can't use json2.js.
What's the state of the art in [de]serialization of JavaScript objects…

Stewart Johnson
- 14,281
- 7
- 61
- 70
48
votes
6 answers
Is Jackson really unable to deserialize json into a generic type?
This is a duplicate question because the following questions are either messy or they are not answered at…

lisak
- 21,611
- 40
- 152
- 243
48
votes
3 answers
Deserialize a JSON array in C#
I've a JSON string of this format:
[{
"record":
{
"Name": "Komal",
"Age": 24,
"Location": "Siliguri"
}
},
{
"record":
{
"Name": "Koena",
"Age": 27,
…

Arnab Das
- 3,548
- 8
- 31
- 43
47
votes
1 answer
Deserialize XML To Object using Dynamic
Is it possible Deserialize unknown XML to object like below?
var xml = @"Arul 90 ";
var serializer = new XmlSerializer(typeof(DynamicObject));
dynamic students =…

user1875919
- 483
- 1
- 5
- 4
46
votes
7 answers
Json.NET: Deserializing nested dictionaries
When deserializing an object to a Dictionary (JsonConvert.DeserializeObject>(json)) nested objects are deserialized to JObjects. Is it possible to force nested objects to be deserialized to Dictionarys?

Daniel
- 47,404
- 11
- 101
- 179
45
votes
4 answers
Swift 4 Codable; How to decode object with single root-level key
I'm using the Swift 4 Codable protocol with JSON data. My data is formatted such that there is a single key at the root level with an object value containing the properties I need, such as:
{
"user": {
"id": 1,
"username": "jdoe"
}
}
I…

Joshua Breeden
- 1,844
- 1
- 16
- 29
44
votes
2 answers
What is the use of @Serial annotation as of Java 14
Java 14 introduces a new annotation @Serial in the java.io package. Its brief description in the API docs:
Indicates that an annotated field or method is part of the serialization mechanism defined by the Java Object Serialization…

Nikolas Charalambidis
- 40,893
- 16
- 117
- 183
44
votes
1 answer
Jackson Json and no such method errors
I am trying to use jackson to serialize and deserialize a POJO. Going from POJO to JSON works perfectly but going the other direction does not.
I have a POJO
public class Event {
private String kind;
public String getKind() {
return kind;
…

austinbv
- 9,297
- 6
- 50
- 82
44
votes
7 answers
Newtonsoft JSON - Dynamic Objects
I am using the Newtonsoft JSON library to perform dynamic deserialisation on incoming raw JSON and have found something that I just can't explain.
The starting point is the following JSON string:
{
"task": {
"dueDate": "2012-12-03T00:00:00"
…

MrEyes
- 13,059
- 10
- 48
- 68
44
votes
2 answers
Jackson - Deserialising JSON string - TypeReference vs TypeFactory.constructCollectionType
To deserialise JSON string to a list of class, different ways listed at StackOverflow question
Type 1 (docs link):
List someClassList = mapper.readValue(jsonString, typeFactory.constructCollectionType(List.class, SomeClass.class));
Type…

Arun
- 1,729
- 1
- 14
- 20
43
votes
3 answers
How can I pass complex objects as arguments to a RESTful service?
I have successfully set up a quick test of creating a "REST-like" service that returns an object serialized to JSON, and that was quite easy and quick (based on this article).
But while returning JSON-ified objects was easy as peach, I have yet to…

oligofren
- 20,744
- 16
- 93
- 180
42
votes
3 answers
Deserializing heterogenous JSON array into covariant List<> using Json.NET
I have a JSON-array containing objects of different types with different properties. One of the properties is called "type" and determines the type of the array item. Here is an example of my data:
[{
type : "comment",
text :…

Alexander Galkin
- 12,086
- 12
- 63
- 115