Questions tagged [deserialization]

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

7954 questions
29
votes
4 answers

jackson deserialization json to java-objects

Here is my Java code which is used for the de-serialization, i am trying to convert json string into java object. In doing so i have used the following code: package ex1jackson; import com.fasterxml.jackson.core.JsonGenerationException; import…
MAHI
  • 9,263
  • 11
  • 36
  • 47
28
votes
1 answer

How do I implement TypeAdapterFactory in Gson?

How do I implement type TypeAdapterFactory in Gson? The main method of create is generic. Why? The registration method registerTypeAdapterFactory() does not receive type a type argument. So, how does Gson know which classes are processed by the…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
28
votes
6 answers

Jackson JSON Deserialization: array elements in each line

I am using Jackson and would like to pretty-print JSON such that each element in arrays goes to each line, like: { "foo" : "bar", "blah" : [ 1, 2, 3 ] } Setting SerializationFeature.INDENT_OUTPUT true only inserts newline…
lyomi
  • 4,230
  • 6
  • 30
  • 39
27
votes
2 answers

Jackson Deserialize Variable as Json String

I have a model like that: private String message; private Integer errorCode; private String data; I get for example the following JSON from remote: {"data": {"cat": "1.2.3.4", "ner": "80", "name": "pinta" }, "message" : "m", "errorCode" :…
kamaci
  • 72,915
  • 69
  • 228
  • 366
27
votes
11 answers

Spring Boot Page Deserialization - PageImpl No constructor

Trying to unit test receiving a page from spring boot. If used with javascript the page can be easily be deserialized, but with java, it fails. Have added a default constructor for spring (which is an accepted answer in another stackoverflow post)…
GSUgambit
  • 4,459
  • 6
  • 25
  • 31
27
votes
4 answers

How to create a custom deserializer in Jackson for a generic type?

Imagine the following scenario: class Foo { .... } class Bar { Foo foo; } I want to write a custom Jackson deserializer for Foo. In order to do that (for example, in order to deserialize Bar class that has Foo
Krešimir Nesek
  • 5,302
  • 4
  • 29
  • 56
27
votes
5 answers

Can Haskell functions be serialized?

The best way to do it would be to get the representation of the function (if it can be recovered somehow). Binary serialization is preferred for efficiency reasons. I think there is a way to do it in Clean, because it would be impossible to…
26
votes
1 answer

Error converting value {null} to type 'System.DateTime' in input json

This JsonSerializationException was thrown when I tried to input the following DateTime parameters in my Json : "Error converting value {null} to type 'System.DateTime' in input json" I have given the input here : string inputJSONString =…
Atif Qadri
  • 462
  • 1
  • 5
  • 15
26
votes
3 answers

How serialization works when only subclass implements serializable

Only subclass has implemented Serializable interface. import java.io.*; public class NewClass1{ private int i; NewClass1(){ i=10; } int getVal() { return i; } void setVal(int i) { this.i=i; …
Ravi
  • 30,829
  • 42
  • 119
  • 173
26
votes
3 answers

Json deserialization into other class hierarchy using Jackson

Now i'm working with Jackson and i have some questions about it. First of all. I have two services, first is data collecting and sending service and second receive this data and, for example, log it into a file. So, first service has class hierarchy…
pbespechnyi
  • 2,251
  • 1
  • 19
  • 29
25
votes
3 answers

Force GSON to use specific constructor

public class UserAction { private final UUID uuid; private String userId; /* more fields, setters and getters here */ public UserAction(){ this.uuid = UUID.fromString(new com.eaio.uuid.UUID().toString()); } public…
frail
  • 4,123
  • 2
  • 30
  • 38
25
votes
1 answer

Jackson deserialization on multiple types

I have an abstract class called Instance and then two implementations of that, UserInstance and HardwareInstance. The issue I am having is that when I call the rest endpoint for a @POST into the database, I ideally wanted it to be like…
erp
  • 2,950
  • 9
  • 45
  • 90
25
votes
1 answer

XML deserialization to POJO using Jackson XmlMapper

Using Jackson XmlMapper annotations, how would I deserialize this XML into a pojo? Username1
Bert
  • 363
  • 1
  • 3
  • 6
25
votes
1 answer

Java: Jackson polymorphic JSON deserialization of an object with an interface property?

I am using Jackson's ObjectMapper to deserialize a JSON representation of an object that contains an interface as one of its properties. A simplified version of the code can be seen here: https://gist.github.com/sscovil/8735923 Basically, I have a…
Shaun Scovil
  • 3,905
  • 5
  • 39
  • 58
25
votes
1 answer

How do I deserialize a JSON array and ignore the root node?

I have next response from server - {"response":[{"uid":174952xxxx,"first_name":"xxxx","last_name":"xxx"}]} I am trying to deserialize this in next way - JsonConvert.DeserializeObject(json); Where T = List of VkUser, but I got…
tony
  • 359
  • 1
  • 3
  • 15