Questions tagged [flexjson]

Flexjson is a lightweight library for serializing and deserializing Java objects into and from JSON.

Flexjson - JavaScript Object Notation (aka JSON) is a very popular alternative to XML for transmitting data to the web browser. Flexjson is a lightweight library for serializing and deserializing Java objects into and from JSON. What's different about Flexjson is it's control over what gets serialized allowing both deep and shallow copies of objects. Most JSON serializers mimic object serialization libraries and try to serialize the entire object graph from the object being turned into JSON. This causes problems when you want a connected object model in your server, but you can't send that object model to the client because the serialization library will try to send the entire object graph. This makes it very hard to create object oriented models and serialize pieces of that model to the client without sending everything. Other JSON libraries require you to create a lot of boiler plate code to translate your object representation into a JSON object. In this regard I shouldn't have to explain myself, but to keep it short let's me just say I hate boiler plate translation code! Flexjson tries to solve both of these problems by offering a higher level API or dare I say DSL for specifying your intent.

Official Website: http://flexjson.sourceforge.net/

Useful Links:

87 questions
2
votes
1 answer

FlexJSON - JSONDeserializer String Cannot be caste as Boolean

I am using FlexJson within my play framework application but at the point I am trying to deseralize the json string it throws a java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean: User user = new…
Chahal
  • 109
  • 1
  • 10
2
votes
1 answer

How to use Flexjson JSONDeserializer?

I have a string: [{"product_id":"2","name":'stack"'},{"product_id":"2","name":"overflow"}]" How can I use Flexjson's JSONDeserializer to obtain all product_ids from the above string? I have a class called productinformation which has fields like…
saurabh ranu
  • 1,351
  • 6
  • 18
  • 24
2
votes
0 answers

Getting Partial Response in FLEXJSON serializer

I am using the Rest full web-service in one of my project . As per my business module I should not give complete object module in the json response. To achieve that I am using flex JSON serializer. Wit flex json I am able to serialize the object…
LOKESH
  • 21
  • 3
2
votes
2 answers

Android array to Sharedpreferences with Gson

I need to create an array of the last 5 call dates. I know that I have to save the date on the array but I don't know how to reorder the other records to keep this last call date the 1st record. And always maintain only 5 records The Goal is to save…
FilipeOS
  • 801
  • 1
  • 11
  • 42
2
votes
3 answers

Convert QueryString to Json using JAVA

I want to convert "id=1&location=india" querystring to {"id":"1","location":"india"} json format using java. I am using spring version 4.0.3.
Devloper
  • 120
  • 3
  • 14
2
votes
2 answers

Excluding fields during json serialization

I'm trying to use FlexJSON to serialize a java object. The object has some top level fields and a collection called results. From within the collection I only want a few properties but all of them are being serialized. Here is the code I'm…
gunygoogoo
  • 641
  • 2
  • 7
  • 19
2
votes
1 answer

Deserializing JSON object

I am having trouble deserializing a JSON object. The object contains a collection which is being deserialized as a Map, which is the default. I need it to deserialize as a Set. My code is as follows: TaskDetail.java @ManyToMany private…
Neriyan
  • 155
  • 2
  • 2
  • 14
2
votes
1 answer

flexjson: Could not load class

I'm new to flexjson. I tried the following java code for my test: "FlexjsonTest.zip". The result of running the program is in "Protocol.txt". I ran the code from the command line: javac FlexjsonTest.java java Flexjson I use flexjson 2.1 . Using…
2
votes
2 answers

Java can't deserialize JSON

I'm getting an error trying to deserialize what I believe is a valid JSON string: String json = "{\"email\":\"testing@example.com\",\"password\":\"12345\"}"; // FlexJSON deserializer JSONDeserializer deserializer = new…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
2
votes
1 answer

How to serialize Map with values being Lists to JSON?

I need to serialize this particular object with flexJSON 2.0: public class DiagramNodeDataSerializableRepresentation { private List nodes; private Map> connections; public…
2
votes
1 answer

Flex JSON unable to properly serialize/deserialize LinkedHashMap

I tried to serialize and deseriliaze LinkedHashMap data as follow: LinkedHashMap o = new LinkedHashMap(); o.put("1", "a"); o.put("2", "b"); o.put("3", "c"); o.put("4", new…
cix.yong
  • 35
  • 3
  • 9
2
votes
1 answer

FlexJSON Orders Alphabetically by Default

How do I use a custom order when using FlexJSON 2.1 with Play Framework? Right now I have: public String toJsonString() { // Include id & name, exclude all others. JSONSerializer ser = new JSONSerializer().include( "id", …
eliot
  • 1,319
  • 1
  • 14
  • 33
1
vote
1 answer

FlexJSON Exclude Properties Upon Deserialization

I'm receiving a JSON response from a web service, but for various reasons I don't want to have certain properties deserialized in the final response object. For example I have: public class Foo { private String bar; private int baz; …
Alex Beardsley
  • 20,988
  • 15
  • 52
  • 67
1
vote
2 answers

How to force FlexJson in java to deserialize a json object to a string?

So I'm getting an object back from a server that looks like this: { "Status": { "stuff":"stuff..."; "morestuff":"morestuff..."; }; "Data": { ... another object ... }; } However, when I get this object back, I want to…
Nico
  • 1,181
  • 2
  • 17
  • 35
1
vote
0 answers

FlexJson deserialization with custom ObjectFactories

I am using FlexJson to support my entities with JSON. But I do have some problems deserializing them, because I want a "short data amount" to reduce the data volume sent between backend and client. Lets suggest we do have a Person class which…
Alexander
  • 7,178
  • 8
  • 45
  • 75