Questions tagged [jsonserializer]

The JsonSerializer enables to control how objects are encoded into JSON. JSONSerializer will also pay attention to any method or field annotated by JSON.

JSONSerializer is the main class for performing serialization of Java objects to JSON. JSONSerializer by default performs a shallow serialization. While this might seem strange there is a method to this madness. Shallow serialization allows the developer to control what is serialized out of the object graph. This helps with performance, but more importantly makes good OO possible, fixes the circular reference problem, and doesn't require boiler plate translation code.

A simple example:

JSONSerializer serializer = new JSONSerializer();
return serializer.serialize( person );

Source:

Related tags:

512 questions
15
votes
3 answers

Jackson deserializing into Map with an Enum Key, POJO Value

I am trying to deserialize JSON into a Java POJO using Jackson. Without giving away confidential information, here is an example stack trace when ObjectMapper's deserialization fails: org.codehaus.jackson.map.JsonMappingException: Can not construct…
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
13
votes
1 answer

JSON serialized object gives error with multiprocessing calls - TypeError: XXX objects not callable error

I am using JSON serializer helper function to easy access of dictionary(basically received as JSON) objects. jsondict.py """Utilities for working with JSON and json-like structures - deeply nested Python dicts and lists This lets us iterate over…
user1992
  • 169
  • 1
  • 15
13
votes
4 answers

flutter dart JsonSerializable with inherited class

I have the following two classes where one is extending from the other like this : @JsonSerializable(nullable: true) class Response { final String responseCode; final String responseMessage; final String errorLog; Response({this.errorLog,…
Baraa Aljabban
  • 992
  • 13
  • 22
13
votes
1 answer

How to invoke another serializer from a custom Gson JsonSerializer?

I have my custom class User: class User { public String name; public int id; public Address address; public Timestamp created; } I'm now creating a custom JsonSerializer for User.class: @Override public JsonElement serialize(User…
Jonas
  • 121,568
  • 97
  • 310
  • 388
13
votes
1 answer

Remove concrete __type information in JSON Response using JsonSerializer

How do you force the __type information from rendering in the deserialized JSON response? I have no need to reserialize this data so I'd prefer to remove it. ServiceStack seems to add this to the dictionary properties of my model. This is using…
Steve Stevenson
  • 637
  • 1
  • 7
  • 7
12
votes
2 answers

Cannot Convert From String to NewtonSoft.Json.JsonReader

I am new in Xamarin Forms and I am trying to create a method that requests a list of items from an API. However, I am not able to compile the solution due to the error message "Cannot Convert From String to NewtonSoft.Json.JsonReader" in the…
Henry
  • 167
  • 1
  • 1
  • 8
12
votes
7 answers

Grails - grails.converters.JSON - removing the class name

Is there a way to remove the class field in a JSON converter? Example: import testproject.* import grails.converters.* emp = new Employee() emp.lastName = "Bar" emp as JSON as a string is …
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
12
votes
3 answers

Is there any way to JSON.NET-serialize a subclass of List that also has extra properties?

Ok, we're using Newtonsoft's JSON.NET product, which I really love. However, I have a simple class structure for hierarchical locations that look roughly like this... public class Location { public string Name { get; set; } public…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
11
votes
3 answers

Serialize JSON string that contains escaped (backslash and double quote) Swift return Badly formed object

I have response string from the backend like this: { "status": "success", "data": "{\"name\":\"asd\",\"address\":\"Street 1st\"}" } I think the problem was because the double quote (") in the data String. When I remove the double quote, the…
Jefferson Setiawan
  • 536
  • 1
  • 5
  • 22
11
votes
3 answers

django object is not JSON serializable error after upgrading django to 1.6.5

I have a django app which was running on 1.4.2 version and working completely fine, but recently i updated it to django 1.6.5 and facing some wierd errors like below Actually i am getting this during user/client registration process in my site…
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
11
votes
2 answers

Using Jackson JSON Generator, how can I write multiple objects to one field?

Suppose I have the following three classes (getters and setters left out for brevity): @JsonAutoDetect public class InfoCollection{ private InfoType1 info1; private InfoType2 info2; } @JsonAutoDetect public class InfoType1{ private…
CFL_Jeff
  • 2,589
  • 3
  • 31
  • 49
10
votes
4 answers

Get .NET Core JsonSerializer to serialize private members

I have a class with a private List property which I would like to serialize/deserialize using the JsonSerializer. Use of the JsonPropertyAttribute doesn't seem to be supported in .NET Core. So how can I have my private list property…
Mats
  • 14,902
  • 33
  • 78
  • 110
10
votes
2 answers

Cannot find DataContractJsonSerializer from an Asp.Net Mvc application

I can't get access to the DataContractJsonSerializer method from System.Runtime.Serialization.Json If I do: using System.Runtime.Serialization.Json; I get an error... How can I access this in my Asp.Net Mvc app so I can use the…
Matt
  • 5,547
  • 23
  • 82
  • 121
9
votes
3 answers

How to serialize into a json from entity?

I'm trying to serialize an (Entity Framework 6) entity into json. I am making sure the entry is in memory before serializing via the AsNoTracking() method however I get an error as it cant receive a value form a different table that is referenced in…
user5524649
9
votes
2 answers

How to pass parameter to JsonSerializer?

I have a simple data service : @GET public Data getData(@QueryParam("id") Long id) { Data data = dataService.getData(id); return data; } And a matching DataSerializer that implements JsonSerializer : The DataSerializer is registered to…
smallufo
  • 11,516
  • 20
  • 73
  • 111
1
2
3
34 35