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

JSON serialize gives null in the java POJO

I have a java POJO with values set. i set values like the following : CreateRequisitionRO[] request = new CreateRequisitionRO[1]; request[0].setPortfolio("HEXGENFUND"); request[0].setTransSrlNo(new BigDecimal(1)); …
Java Questions
  • 7,813
  • 41
  • 118
  • 176
0
votes
2 answers

Python list, tuple and dictionary to JSON?

What's the best way of displaying this as JSON? {'foo': 'bar'} [1,2,3,4,5] My partial solution: import json def json_tuple(*args, **kwargs): if args: if kwargs: return json.dumps(args), json.dumps(kwargs) return…
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
1 answer

How to format data in Json file with a variable assignment

I am having a converting that in to Json with following code JSONObject jsonformatted = (JSONObject)JSONSerializer.toJSON(map); FileWriter writer = new FileWriter("myfile.json"); It is working fine and out put is following […
Amit
  • 196
  • 4
  • 16
0
votes
2 answers

A c# JavaScriptSerializer serialized string has backslashs that cause problems in javascript

I have line of c# code in ASP.NET MVC view that string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model); If I debug this string is "{\"Age\":14}" So when I assign this string to my javascript code, it…
Ray
  • 12,101
  • 27
  • 95
  • 137
0
votes
1 answer

JSON serialization of MongoDB ObjectID (ex-scope query)

I am confused howcome the variable temp_dict is available outside else condition? when I am saving the array to MongoDB which is setting the ObjectId on each item in the array. Json parser doesn't doesn't know how to serialize ObjectId. def…
Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66
0
votes
1 answer

How to override json serialization of a System.Web.Script.Services.ScriptMethod

What is the best practice way to override the serialization (serialisation) for a class? Specifically I have Key/Value pair collection. The default generated JSON looks like…
DJL
  • 2,060
  • 3
  • 20
  • 39
0
votes
1 answer

Why are updated element values not being passed?

I currently check if an input/textarea/checkbox/select changes and if so then I want to initiate my function to search the database and update the 'results' div. Now this is what I have so far.. It works on change no problem, the only issue is now…
Braunson
  • 717
  • 2
  • 12
  • 36
0
votes
1 answer

PHP.js unserialize() error IE7

I try to serialize object data to be saved into a file by php using serialize package by PHP.js. Chrome: fine FF: fine IE9: fine IE9 in compatibility mode (essentially IE7): not fine. Error from console: SCRIPT5022: Exception thrown and not caught…
Simon Josef Kok
  • 745
  • 1
  • 8
  • 22
0
votes
1 answer

WebApi jsonFormatter how to change Null String values to Empty String

Im receiving quirky issues with my json data from my asp.net MVC WebApi coming into my kendoUI controls because null strings are being sent across as "FielName":null Im wondering how do I go about setting up the jsonformatter on my webapi so that…
Matt
  • 3,305
  • 11
  • 54
  • 98
0
votes
1 answer

JsonSerializer field order (don't want alphabetical) - Java

I'm using JsonSerializer to convert an Object to a JSON String but the order is wrong. The attributes are automatically sorted alphabetically but I want them in the order they have been listed in the class (e.g. "endPoint" should not appear before…
0
votes
1 answer

deserializing string array in c# for wp7

This is the structure of my JSON: string sample = "[{'Disp_Name':'avi garg', 'emailId':'avi@india.com', 'fName':'avi', 'lName':'garg', 'ph':{'number':'9813612344(Mobile)','type':1} }, {'Disp_Name':'monk…
0
votes
1 answer

jackson serializer: get serialized object

I have a problem with Serializer, here is my problem : I have a bean class like that : @JsonSerialize(using = MyObjectSerializer.class) public class MyObject { public int a; public boolean b; } When Serializing through Jackson, without the…
Salomon BRYS
  • 9,247
  • 5
  • 29
  • 44
0
votes
1 answer

Json() in MVC converts datetime to UTC automatically

I am already storing UTC time in DateTime objects. When I send this across using Json() serializer these dates are again converted to UTC. I don't want this to happen. Please help.
Gautam Jain
  • 6,789
  • 10
  • 48
  • 67
-1
votes
1 answer

Json Serializer Populate with CreateReader not mapping

Could be one of those days where I can't see what is infront of me but when I try to use the jsonserializer Populate function to map to an object - it fails to do so, and I'm not sure why. the object returned just has the default values for…
-1
votes
2 answers

compares two JSON-objects and returns a JSON-object with a list of the differences c#

I'm converting View Model into a JSON Object and inserting into the Database. Now I want to pick any two JSON objects from the database and compare both the JSON objects and see if there is any change in the attribute value and return the list of…