genson

How to serialize/deserialize Kotlin sealed class?

混江龙づ霸主 提交于 2020-05-26 12:09:31
问题 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? I've tried to use Genson serializer/deserializer library - it can handle Kotlin data classes, it's also possible to support polymorphic types (eg. using some metadata to specify concrete types). However, the library fails on Kotlin object types, as these are

Could not parse date in RESTful application with Jersey

岁酱吖の 提交于 2019-12-13 14:49:53
问题 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 eclipselink.version 2.5.2-M1. How do I fix this? Resource @POST @Path(value = "/") @Consumes(MediaType.APPLICATION_JSON) public Response saveDate(DateMapper date) { dateService.save(date); return Response.status(Response.Status.OK).entity("Date has been

Genson with Jersey JsonBindingException: Could not deserialize to type class java.lang.String

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:55:00
问题 In my Spring MVC Java application I'm using Jersey REST API. I am using Jackson for JSON processing. I added Genson to my project for filtering some fields for some classes. And I am trying to use Genson only for that and remaining I want to use Jackson. But I am getting exception while using Jersey REST api as Jersey enabled Genson by default when the Jar is in the classpath (Got to know from this link). Here is my code in connect to web service and get data and convert to String using

Genson with Android - Proguard config

限于喜欢 提交于 2019-12-11 07:39:37
问题 I have a problem with proguard config in Android Project. I'm using Genson to parse incoming JSON data. It is fast and there is no need for extra configuration or deserializers, because on the Server-side there is also Genson. Everything works fine in debug mode, but in release, with proguard it doesn't. Unfortunately I have some error during runtime: FATAL EXCEPTION: main Process: com.es.mobile.meedy, PID: 16650 java.lang.UnsupportedOperationException: Couldn't find parameter at 0 from type

My first web client giving “MessageBodyWriter not found for media type…” (JSON)

强颜欢笑 提交于 2019-12-11 04:43:50
问题 I'll give you the short story first. If I, in Eclipse, export my jar file with jar files (the Runnable Jar wizard and select "Package required libraries...") instead of "Extract required libraries", every thing works, but it is excruciatingly slow to get going. If I build my jar with the extracting method the code will cause an eventual org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json I'm not using Maven. I

What is a ContextResolver and Provider in Jersey?

夙愿已清 提交于 2019-12-11 01:54:27
问题 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 directory contains a file called "org.glassfish.jersey.internal.spi.AutoDiscoverable". Following that AutoDiscoverable path, by default Genson/Jersey auto-registers a the following class: @Provider @Consumes({MediaType.APPLICATION_JSON, "text/json",

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

拟墨画扇 提交于 2019-12-02 01:11:26
问题 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 unexpected. Now, if I were to do this as a servlet, using Gson, I set the date format on a Gson instance that I maintain. That forces the parse of the POJO to use the correct format. I see that Genson has a similar interface, but I don't know how to get the

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

六月ゝ 毕业季﹏ 提交于 2019-12-01 22:26:26
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 unexpected. Now, if I were to do this as a servlet, using Gson, I set the date format on a Gson instance that I maintain. That forces the parse of the POJO to use the correct format. I see that Genson has a similar interface, but I don't know how to get the instance from the Jersey servlet service or maybe the Spring context so that I cat set the format. So,