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

Trying to remove data in Fractal by implementing ArraySerializer in Laravel 5.2

I've got the API working using the standard process, but I want to remove the data namespace from the JSON output. I see I need to implement ArraySerializer, I have been through the Fractal docs, but I can't work out where I need to added it in…
Jack Barham
  • 3,197
  • 10
  • 41
  • 62
8
votes
3 answers

In C#, how do I model a JSON object with multiple nested arrays?

I am getting this JSON response from a system I am connecting to and trying to figure out the best way to deserialize it into a C# object. I am currently using RestSharp which seems pretty straight forward to use but the format of the JSON is…
leora
  • 188,729
  • 360
  • 878
  • 1,366
8
votes
2 answers

Is there a JavaScript (client-side) JSON library that integrates well with JSON.NET (server-side) and supports the "preserve references" feature?

JSON.NET supports circular reference serialization by preserving all references with the following settings: JsonSerializerSettings settings = new JsonSerializerSettings(); settings.ReferenceLoopHandling =…
Triynko
  • 18,766
  • 21
  • 107
  • 173
7
votes
2 answers

Deserialize enums using the EnumMember value in AspNet [FromQuery] model binding

I have an endpoint in .NET 6 Microsoft.NET.Sdk.Web project that deserialize query strings into a .NET object by using the standard [FromQuery] [Route("[controller]")] public class SamplesController : ControllerBase { [HttpGet] public…
7
votes
2 answers

JsonSerializer.Deserialize is returning empty object

I have a webapi that returns some Json: {"id":9,"businessName":"dummy","address":"pluto","products":[ {"id":762,"description":"Centralized needs-based…
7
votes
1 answer

How to use Gson to serialize objects in android?

I want to send 2 objects to Java server from Android client using socket (as I am developing a Remote PC). AndroidClient.java public class MainActivity extends Activity{ Socket client; ObjectOutputStream oos; …
Suroor Ahmmad
  • 1,110
  • 4
  • 23
  • 33
6
votes
3 answers

How to exclude null-value fields when using Flexjson?

I am serializing a class like this into JSON using Flexjson: public class Item { private Long id; private String name; private String description; ... // Getters and setters ... } Many of the Item fields can be null (e.g.,…
Matthias
  • 230
  • 1
  • 3
  • 9
6
votes
0 answers

Setting Blazor Server Application JsonSerializerOptions

When you have an MVC application you can append services.AddMvc().AddJsonOptions(options => ... and that will set the Json options for all the controllers. What is the equivalent for a Blazor Server App? I tried…
Cef
  • 661
  • 1
  • 6
  • 26
6
votes
3 answers

Firebase Documentsnapshot map to Json object in Flutter

I am trying to map a DocumentSnap from Firebase to a Json Class in Flutter. I can confirm that my is getting the data from the document, but i cannot pass the gathered data to my Json object. I have attached code and error message. Class for getting…
6
votes
3 answers

how to map a JSON to a java model class

I need to map JSON obj to a class and its arrays to ArrayList in Android and it should have all the children data as well. (with nested arraylists too) and i need to convert updated data list again to jsonobject my json string is { "type":…
6
votes
3 answers

Deserializing BSON ReadBsonType can only be called when State is Type

I have the following Code: using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver; using MongoDBTest; using ServiceStack; using System; using…
SiriSch
  • 180
  • 1
  • 3
  • 16
6
votes
1 answer

Which is better to use for serialization objects? JsonSerializer or JsonConvert

I want to serialize object in c# and learn that we can do this both JsonSerializer and JsonConvert. I know about documentation knowledges about these. But I want to know which is better to use for serialization objects? JsonSerializer or…
6
votes
3 answers

How to unit test a custom Jackson JsonSerializer?

I wrote the following JsonSerializer to let Jackson serialize an array of integers into JSON: import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import…
JJD
  • 50,076
  • 60
  • 203
  • 339
5
votes
1 answer

Bad state: Unexpected diagnostics: Expected an identifier. [SEVERE] json_serializable:json_serializable on test/widget_test.dart

Json serilizable is not working how do i resolve this i have no idea about this error. I used flutter build_runner: ^1.7.2 json_serializable: ^3.4.1 analyzer: ^0.39.17 json_annotation: ^3.0.1 not a single file is creating json Json serilizable…
Lalit Rawat
  • 1,022
  • 2
  • 17
  • 39
5
votes
1 answer

Resolve N + 1 in case of instance dependent scope

So, I have trouble with Preloading instance dependent scopes are not supported. I have three models class P < ApplicationRecord has_many :as has_many :cs end class C < ApplicationRecord belongs_to :p end class A < ApplicationRecord …
Xiting
  • 881
  • 8
  • 16
1 2
3
34 35