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
3
votes
1 answer

ServiceStack Json Serializer ignore properties

I have a business requirement to only send permissioned properties in our response payload. For instance, our response DTO may have several properties, and one of them is SSN. If the user doesn't have permissions to view the SSN then I would never…
Nick H
  • 245
  • 2
  • 13
3
votes
1 answer

ServiceStack JSON Type definitions should start with a '{'

I have a table abstract public class TableDefault { [Index(Unique = true)] [Alias("rec_version")] [Default(typeof(int), "nextval('rec_version_seq')")] [Required] public int Rec_Version { get; set; } …
Tuan Hoang Anh
  • 994
  • 12
  • 31
3
votes
1 answer

ServiceStack JsonSerializer not serializing public members

I'm trying to use ServiceStack.Redis and i notice that when i store an object with public members and try to get it later on i get null. I checked and found that ServiceStack.Redis is using ServiceStack.JsonSerializer so I've tried to create a test…
Omri
  • 887
  • 8
  • 24
3
votes
1 answer

ASP.NET MVC4 Error during serialization or deserialization JSON - big data

I am writing to you with an error in website: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Used technologies: C #,. NET FW 4.5,…
czWolfHunter
  • 387
  • 2
  • 5
  • 17
3
votes
2 answers

How to serialize Map> with FlexJSON

I have a object which I want to serialize to JSON. This object is a map with list of a specific objects. This looks similar to it: Map> map = new Map>(); I am using FlexJSON. I can work only with…
woyaru
  • 5,544
  • 13
  • 54
  • 92
3
votes
3 answers

Conditional ScriptIgnore for JSON Serialization

Is there a way to conditionally exclude items from JSON serialization? I'm using C# in a .NET4 application with WebAPI. I have [DataMember] and [ScriptIgnore] already on my classes and everything works fine. What I want to do is not include…
kyle
  • 268
  • 6
  • 18
2
votes
2 answers

Is there any Java support for JSPON serialization with references?

I'm looking for a Java JSPON serializer that can handle references according to the JSPON specification. Are there any available that can do this currently? Or is there any way to modify an existing serializer to handle object refs with the $ref…
ant-depalma
  • 2,006
  • 4
  • 26
  • 34
2
votes
2 answers

How to serialize class that derives from class decorated with DataContract(IsReference=true)?

I have class A that derives from System.Data.Objects.DataClasses.EntityObject. When I try to serialize using var a = new A(); DataContractJsonSerializer serializer = new…
theateist
  • 13,879
  • 17
  • 69
  • 109
2
votes
2 answers

Enum response is numeric value and not string

For all my other enum classes swagger shows the string definition but for one enum class that I use in my 'ExceptionMiddleware' class it shows the numeric value. But in the swagger documentation example it shows the string value.. My enum class…
user7849697
  • 503
  • 1
  • 8
  • 19
2
votes
3 answers

kotlin: nested polymorphic serialization with generics

I want to serialize Map and one of the values type is Pair. How to register the Pair as polymorphic subclass for that? val module = SerializersModule { polymorphic(Any::class) { subclass(Int::class,…
A-_-S
  • 680
  • 5
  • 21
2
votes
0 answers

When make "Size" class to json, It is something weird in .net

I had used Size class to store width/height of something. But Size class can store only integer value. So I created MySize class made up of doubles and used it. And weird thing was occurred. Serializing class Size and class MySize to json gives…
takeyourcode
  • 375
  • 4
  • 17
2
votes
2 answers

How to add indentation to JSON string to fix formatting using JsonSerializer?

A web service is sending me a JSON string. It contains a valid JSON string, but it is poorly formatted. Is there a way I can format it to better display it on the screen? I was hoping to apply something like this: JsonSerializerOptions() {…
Stout
  • 463
  • 8
  • 19
2
votes
0 answers

Don't unescape unicode characters in System.Text.Json

I have the following JSON string that I read with the System.Text.Json library and I want to deserialize: { "name": "\ud092\u00d0" } When I use the JsonSerializer.Deserialize method it of course decodes the \uXXXX to the appropriate…
Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
2
votes
1 answer

RestSharp: RestClient constructor throws System.IO.FileNotFoundException

I am developing a .NET Core 3.1 Azure Function App in Visual Studio 2022. After upgrading to the latest version of RestSharp today, I'm getting the following exception when I try to instantiate a new…
QBBryant
  • 161
  • 1
  • 11
2
votes
1 answer

put a "Data class" into Kafka using io.projectreactor.kafka:reactor-kafka jsonserializer problem

I could not find any json serializer in reactor-kafka, so i use org.springframework.kafka.support.serializer.JsonSerializer I have also try to use com.fasterxml.jackson.databind.annotation.JsonSerialize instead but it didn't work. can any body help…