Questions tagged [genson]

Genson is a Java-to-JSON API, for serializing and deserializing Java to and from JSON.

Genson is a Java-to-JSON API, for serializing and deserializing Java to and from JSON.

The open source Genson project is hosted at https://github.com/owlike/genson.

Alternatives

Alternative Java-to-JSON binding solutions with similar APIs include Jackson, FastJSON, Google Gson, and svenson. Yet more Java-to-JSON libraries are listed at json.org.

Pros and Cons of the different APIs were and continue to be discussed in the https://stackoverflow.com/questions/338586/a-better-java-json-library post.

Performance

The latest performance benchmarks for Genson and other JSON serialization and deserialization solutions for Java are available at https://code.google.com/p/genson/wiki/Metrics2 and https://github.com/eishay/jvm-serializers/wiki.

60 questions
18
votes
4 answers

How to serialize/deserialize Kotlin sealed class?

I have a following sealed class: sealed class ViewModel { data class Loaded(val value : String) : ViewModel() object Loading : ViewModel() } How can I serialize/deserialize instances of the ViewModel class, let's say to/from JSON format?…
Zbigniew Malinowski
  • 1,034
  • 1
  • 9
  • 22
9
votes
1 answer

Is it possible to serialize/deserialize JSON to Java DTO with extra fields going into a map?

I have a DTO like this: public Foo { public int bar = 123; public Map params; // key1=v1, key2=v2 etc. } I would like it to serialize to/from the following JSON: { "bar": 123, "key1": "v1", "key2": "v2" } Does…
David Tinker
  • 9,383
  • 9
  • 66
  • 98
4
votes
1 answer

How to use Genson provider as default in Jersey client?

I have simple client based on Jersey framework. I want to use Genson as default JSON provider. Firstly I created some class which implemented ContextResolver: @Provider public class GensonCustomResolver implements ContextResolver { …
Alexiuscrow
  • 776
  • 2
  • 15
  • 34
3
votes
1 answer

How do I configure the date formatter through Genson/Jersey?

I'm using Jersey for my RESTful services and Genson to perform my JSON/POJO conversion. There's no setup for Genson, I just drop it into the classpath and it just works, except that it throws an error on date parsing because the format is…
user1442498
  • 305
  • 2
  • 10
2
votes
1 answer

How do I configure Genson to deserialize dates?

I am working on a Java servlet and I need to serialize and deserialize a class into JSON and back. To do this, I am using the Genson library, but I am hitting a snag. Genson fails at deserializing instances of the Date class (java.sql.Date) I have…
2
votes
1 answer

Genson throws ArrayIndexOutOfBoundsException

Genson's internal library code is causing an ArrayIndexOutOfBoundsException because it's trying to index an array which I assume is null. See below. I get the following stack trace: Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at…
KyleM
  • 4,445
  • 9
  • 46
  • 78
2
votes
1 answer

What is a ContextResolver and Provider in Jersey?

What is a ContextResolver in Jersey and what is a Provider? What is the difference between the two? I am using Genson with Jersey. Genson is auto-registered when Jersey finds the Genson JAR on the classpath. The Genson JAR's WEB-INF/services…
KyleM
  • 4,445
  • 9
  • 46
  • 78
2
votes
1 answer

Parse JSON Date from POST with Genson and Jersey

Quick Intro (can be skipped) : Hi, there's a lot of questions and answers about this topic, but sometimes the solution is so simple that you just don't even think about, and because I've lost a lot of time I want to post a complement to all…
Karl.S
  • 2,294
  • 1
  • 26
  • 33
2
votes
1 answer

Parse nested JSON with genson

I'm trying to parse some JSON I get from a web API to Java objects and have some problems. Here is the JSON: { "d":{ "results":[ { "__metadata" { some metadata I'm not interested in }, "attribute1":"attribute id…
Markus Wilhelm
  • 171
  • 2
  • 2
  • 11
2
votes
1 answer

Genson serialization Issue with byte and Date fields

Hi I am using Genson for ser/de for my POJO classes. But there is a problem while serializing a POJO which has a byte field. I haven't tried deserialization of same object. So I don't know whether that's also working. Also there is problem in date…
iCode
  • 8,892
  • 21
  • 57
  • 91
2
votes
1 answer

Could not parse date in RESTful application with Jersey

I do RESTful application to accept and save the date. When I call it with the following JSON {"date": "1997-07-16T19: 20: 30 + 01: 00", "count": 1} I get the error listed below. Without date it works well. I use jersey.version 2.5.1 and…
user1816532
  • 185
  • 4
  • 13
2
votes
1 answer

Deserializing json string to fluid objects with genson

I am trying to convert a simple array of string elements in a json document to a java List, which is inside a bean using genson. I was expecting this to happen automatically, but it is not working. Am I missing something? Here is my…
michaeldd
  • 514
  • 2
  • 6
  • 18
1
vote
0 answers

How to fix - UserWarning: Pydantic serializer warnings?

What is the meaning of these warnings and how to fix them? What kind of issues it can create? UserWarning: Expected `Union[list[definition-ref], definition-ref, bool]` but got `JsonSchemaObject` - serialized value may not be as expected Expected…
shaik moeed
  • 5,300
  • 1
  • 18
  • 54
1
vote
1 answer

Genson deserialize a list of given types

I'm writing a help function. getList will get serialized data from somewhere, and deserialize it. getList always returns a List. Users will specify the type of the elements. The expected usage is like this: List l1 = getList("Asset");…
Gqqnbig
  • 5,845
  • 10
  • 45
  • 86
1
vote
0 answers

Genson failed to serialize in JDK7

I have a JAX-RS client which is as follow: MyObj myObj = new MyObj(); myObj .setRemark("My test case"); myObj .setSomeDate( LocalDate.now()); ... WebResource webResource = client .resource("my_url"); webResource …
xcoder
  • 1,336
  • 2
  • 17
  • 44
1
2 3 4