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

Serialize and deserialize objects from user-defined classes

Suppose I have class hierarchy like this: class SerializableWidget(object): # some code class WidgetA(SerilizableWidget): # some code class WidgetB(SerilizableWidget): # some code I want to be able to serialize instances of WidgetA and WidgetB…
3
votes
0 answers

Swift: send POST request with JSONEncoder encoded data does not work

I am using the JSONEncoder that has been provided with Swift4. I have a class called Customer that uses the Codable protocol. Inside of Customer there are four Strings. class Customer: Codable { var title: String var firstName: String var…
Oliver Koehler
  • 711
  • 2
  • 8
  • 24
3
votes
1 answer

.Net 45 serialisation from .Net Standard 2.0 dll

I have a .Net standard 2.0 app that is referencing some contracts in a .Net45 dll. I was doing it this way under the impression that once these contract objects get serialised they will be done so using the .Net45 assembly types. Deserilising these…
Grace
  • 2,548
  • 5
  • 26
  • 23
3
votes
1 answer

Gson serialize with two List types in a single JSON object

I have two types of list to bind the request using Gson library. I tried in a way, it is working as excepted. But I want to know whether we have any default procedure to serialize the lists. I tried below and working. But this is not the way to…
Abish R
  • 1,537
  • 3
  • 18
  • 36
3
votes
0 answers

TimeZone conversion in WebApi

I am saving all dates in my database as UTC. I now need to adjust to the client's local timezone. Some background. I am using WebApi2 and I have an ASP.Net MVC5 web app consuming it. Eventually native apps will also consume the WebApi2 service. Here…
pieperu
  • 2,662
  • 3
  • 18
  • 31
3
votes
1 answer

JsonInclude.Include.NON_DEFAULT not working with custom serializer

I want to both use a custom serializer and have the JsonInclude.Include.NON_DEFAULT designation be honored. When I don't use a custom serializer it is honored but when I do use a custom serializer it is not. This is Jackson 2.2.2. I do not…
QuantumMechanic
  • 13,795
  • 4
  • 45
  • 66
3
votes
1 answer

Complex JSON object Serialization using C#

I am trying to serialize complex JSON object using C#. I got an initial output through my code.But I want to add another object in an array form before my serialized json. I created C# class from my json object in this way- public class…
harry.luson
  • 247
  • 7
  • 19
3
votes
2 answers

Json Formatting.Indented using Web Api Controller, ASP.NET MVC

I generate a json data for name, shorttext, geolocation ann image information, which I collect from web api. Throug my code I can generate JSON data /api/wiki/name. But I cannot formatting the data. When I want to save it in a file it stores in a…
3
votes
1 answer

Jil serializer ignore null properties

Is there an attribute to prevent Jil from serializing properties that are null ? In Newtonsoft it is : [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Guy Assaf
  • 888
  • 9
  • 24
3
votes
1 answer

How to encode a string into Json string text?

When I try to retrieve SQL table content in to a JSON format in C# eg: the content Baden-Württemberg is retrived as a "Baden-W\u00FCrttemberg" after JSON serilize. I try this byte[] bytes = Encoding.UTF8.GetBytes(input); input =…
Sanjeev S
  • 626
  • 1
  • 8
  • 27
3
votes
1 answer

Calculate distance between 2 zipcodes using google maps API using Asp.Net MVC C#

Today I needed create some functionality to calculate the distance between zipcodes and it was not easy to me. Fortunately I found a good way and I believe it can be helpful to someone else.
Márcio Gonzalez
  • 1,020
  • 1
  • 8
  • 20
3
votes
1 answer

carrierwave double key in serializable_hash

I have a user model which mount a carrierwave uploader for a field called profile_img. code folows: class User < ActiveRecord::Base mount_uploader :profile_img, ProfileUploader end the output of profile_img field is like this: "profile_img": { …
fuyi
  • 2,573
  • 4
  • 23
  • 46
3
votes
3 answers

Coercing Json Serializer into producing a particular datetime format (yyyy-mm-ddThh:mm:ss.msmsmsZ)

MyClass theSession = new MyClass() { accountId = 12345, timeStamp = DateTime.Now, userType = "theUserType" }; System.Web.Script.Serialization.JavaScriptSerializer Json = new…
Chris McCall
  • 10,317
  • 8
  • 49
  • 80
3
votes
2 answers

Scala Pickling for Json serialization and deserialization?

For my project, dijon, I was wondering if it is possible to use Scala pickling for JSON serialization and deserialization. Specifically, I want something like this def toJsonString(json: JSON, prettyPrint: Boolean = false): String and def…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
3
votes
1 answer

How can I configure ServiceStack Json Serializer to write bool values as int or byte?

public class Test { public string Name { get; set; } public bool IsActive {get;set;} } It is serialized as {"Name":"Test1","IsActive":false} But target serialization result is {"Name":"Test1","IsActive":0} PS: I can use…
Oguz Karadenizli
  • 3,449
  • 6
  • 38
  • 73