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
5
votes
2 answers

Serialize dataGridView to JSON

I have a datagridview on my Windows Form Application that takes input from a user. I'd like to use JSON to store this input and am trying to serialize the input from the datagridview into JSON. So far I have: private void…
bucketman
  • 463
  • 6
  • 15
5
votes
1 answer

MappingJackson2HttpMessageConverter Can not find a (Map) Key deserializer for type

Here are the entity classes for my project import java.util.Iterator; import java.util.Map; import java.util.Set; @Entity @Table(name="training") public class Training { @Id @GeneratedValue private long id; private String…
user5761419
5
votes
1 answer

Play Framework - how to ignore some fields for Json Serialisation?

I have case class case class User ( id: Option[Long] = None, username: String, password: Option[String] = None, ) And here is json serialiser for this case class object User { implicit val userWrites: Writes[User] = ( (JsPath \…
Teimuraz
  • 8,795
  • 5
  • 35
  • 62
5
votes
2 answers

Polymorphic serialization using Jackson when return type is marker interface

I have a rest service which returns marker interface and this interface have multiple implementations and don't have any common property in the implementations. @RequestMapping(value = "/users/{userName}", method = RequestMethod.GET) public…
Sunil Kumar
  • 5,477
  • 4
  • 31
  • 38
5
votes
1 answer

laravel Interface 'JsonSerializable' not found

Im using the following for my application for social media login https://github.com/madewithlove/laravel-oauth2 but im getting this error Symfony \ Component \ Debug \ Exception \ FatalErrorException Interface 'JsonSerializable' not found open:…
Karlo
  • 95
  • 3
  • 9
5
votes
1 answer

How to serialize the checkbox in a form into Json data

We know that in MVC, a CheckBoxFor will generate a checkbox with a value="true" and a hidden with a value=false. Both input controls will share the same name. It is very reasonable because the form will be able to POST a false value if the box is…
Blaise
  • 21,314
  • 28
  • 108
  • 169
4
votes
1 answer

MVC 3 - JSON serializer

I have the following model, view and controller. Model public class Person { public string Name;// { get; set; } public string Occupation { get; set; } public int Salary { get; set; } public int[] NumArr { get; set;…
Michael Sync
  • 4,834
  • 10
  • 40
  • 58
4
votes
3 answers

Preventing StackOverflowException while serializing Entity Framework object graph into Json

I want to serialize an Entity Framework Self-Tracking Entities full object graph (parent + children in one to many relationships) into Json. For serializing I use ServiceStack.JsonSerializer. This is how my database looks like (for simplicity, I…
4
votes
3 answers

.NET 6 - AddJsonOptions with CamelCase not working

I have tried use camelCase insentive on .NET 6 for deseralize content from API I configured like this in Startup.cs, but it is not working .AddControllers() .AddJsonOptions(options => { …
4
votes
4 answers

Can I tell the WCF WebAPI serializer to ignore nested class objects?

I am using WCF WebAPI to write REST services using WCF. I am returning my POCO classes as json/xml objects from my service. Most of my POCO classes contain ICollections as they are part of EF4.1 Code First, hence I get error : Cannot serialize…
Anand
  • 4,523
  • 10
  • 47
  • 72
4
votes
3 answers

Flutter json_serializable 5.0.0 is not working along with auto_route

I'm getting below error after upgrading the json_serializable lib from 4.1.4 to 5.0.0 can anyone please explain what is wrong with the versions I'm using? Because no versions of auto_route_generator match >2.1.0 <3.0.0 and auto_route_generator 2.1.0…
4
votes
2 answers

C# JsonSerializer.Serialize returns an empty object

I have faced an issue about serializing struct to JSON. So, I have a struct "Coordinates" namespace CoordinatesNameSpace { public struct Coordinates { public Coordinates(string key, string x, string y, string z) { …
Dmitry Klymenko
  • 173
  • 4
  • 11
4
votes
1 answer

How to send Json Data from controller to javascript without in ASP.NET Core?

I am creating an application in that I need to create Treeview for that I take reference of this site Actually this project is created in MVC Framework and currently, I am using ASP.NET CORE(v3.0) and when I try to send JSON using…
Deep Soni
  • 431
  • 4
  • 24
4
votes
2 answers

Is it possible to simplify @JsonSerialize annotations?

The following code works fine: // works public class MyClass { @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) private LocalDateTime startDate; @JsonSerialize(using =…
DerBenniAusA
  • 727
  • 1
  • 7
  • 13
4
votes
1 answer

Convert JSON String from Camel case to Pascal case using C#

I'm having a JSON string, it has Key in the form of Camel-case but I need to convert the Key to Pascal-case. Actual JSON String string jsonString = "{\"personName\":{\"firstName\":\"Emma\",\"lastName\":\"Watson\"}}"; Expected JSON String : Needs to…
user7784919