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
1
vote
0 answers

Flattening FlexJSON output

I have a class, call it ClassOne, and it has a few fields with getters/setters, one of which is an object of another class, ClassTwo. I'm trying to use FlexJSON to serialize out the ClassOne object, like so: public class ClassOne{ private String…
Billy Mailman
  • 272
  • 11
  • 25
1
vote
1 answer

How do I serialize referenced persistent classes to JSON only using primary keys

I would like to serialize class Foo (that can be persisted) into JSON using flexjson (if you know some other library that support required functionality please speak up). I'd like to include depending reference to class Bar and FooBar, but I only…
mitjap
  • 495
  • 1
  • 6
  • 14
1
vote
0 answers

Serializing list of objects with flexjson

I am playing with flexjson and Google Cloud Endpoints. My model which I need to serialize is: public class SampleModel { Long id; DateTime createdAt; String message; OtherModel other; } I just created DateTimeObjectFactory to find a way of…
sennin
  • 8,552
  • 10
  • 32
  • 47
1
vote
2 answers

Deserializing Json in Android

In my backend I have a class User which has multiple Trips. Those trips have multiple user. This is a circular reference. I use this code in my rest service to serialize the user object: Gson gson = new Gson(); return gson.toJson(user,…
Glenn Obyn
  • 11
  • 1
1
vote
1 answer

FlexJson deserializer not working after obfuscating code

FlexJson is working great with deep serialize where i have objects inside objects..But i see that after obfuscating my build with proguard my deserialized class returns just the class object in String..Or anything i have to change in the…
sheetal
  • 3,014
  • 2
  • 31
  • 45
1
vote
2 answers

create a JSON file and save into disk

how to create a JSON file for any object and save it on disk. after some days retrieve it back?
Devendra
  • 1,864
  • 6
  • 29
  • 49
1
vote
0 answers

Deserialize an enum with flexjson that is received as integer value

we are creating a JSON REST client application that has to communicate with a service written in C#. Most things like difference in dates etc are solved pretty easily with the FlexJson library. But one thing doesn't: Enum values that are sent as an…
Tom
  • 151
  • 1
  • 6
1
vote
2 answers

Lazy Initialization Error with Hibernate and FlexJSON

I'm getting a really strange error trying to serialize a JPA/Hibernate entity with FlexJSON. the object itself is nothing fancy; just fields and relationships between other objects. Caused by: flexjson.JSONException: Error trying to deepSerialize …
Alex Beardsley
  • 20,988
  • 15
  • 52
  • 67
1
vote
1 answer

Example on consuming JSON in Play Framework views

I am trying to make the switch in a controller from sending JPA retrieved items as a List to the template engine to now send these as JSON. I would prefer to use the flexJSON library for the task. What I have is a Application controller with the…
Jes Chergui
  • 1,318
  • 1
  • 22
  • 33
0
votes
1 answer

Leave off field names using FlexJson, Jackson, GSON etc

Right now I'm using the org.json JSON library. JSONArray data = new JSONArray(); for (PkgLoad pkgLoad : list) { JSONArray row = new JSONArray(); row.put(Double.parseDouble(df.format(pkgLoad.ounces))); …
Drew H
  • 4,699
  • 9
  • 57
  • 90
0
votes
1 answer

How to build JSON array line by line(iterate through list). FlexJSON

I'm using FlexJSON(but I'm open to other libraries) and I want to manually build a json array. I have certain things that I need to add that are not part of the model that is being serialized. For instance I want to add an html column and css…
Drew H
  • 4,699
  • 9
  • 57
  • 90
0
votes
1 answer

ConcurrentModificationException in Flexjson

I'm sometimes getting this error when serialising an object flexjson.JSONException: Error trying to deepSerialize at flexjson.transformer.ObjectTransformer.transform(ObjectTransformer.java:61) at…
beek
  • 3,522
  • 8
  • 33
  • 86
0
votes
1 answer

flexjson.JSONException Don't know how to bind

My android application use flexjson library to deserialize json data string received from server via RESTfull webservice. But when deserialize i get error. flexjson.JSONException: [ data.status ]: Don't know how to bind Clock_in into class…
Tung Vo
  • 2,227
  • 5
  • 27
  • 45
0
votes
1 answer

how to convert json to java Obj using flexjson?

Yes. It is my code what convert java obj to JSON using flexjson. It is ok by the test. But I don't know how to convert JSON to java Obj. Anybody knows? Thanks for your help in advance. /** * convert java obj to json using flexjson…
Xiao Key
  • 33
  • 7
0
votes
0 answers

flexjson.JSONException: Cannot instantiate abstract class or interface

I am quite new to use the JSON third party API FlexJson. I am using this jar for deserialize the JSON to java Object(user defined). The class contains two array objects. When i use this jar to deserialize this json to my object an error is…
Marvel John
  • 193
  • 1
  • 3
  • 14