Skip to main content

Convert JsonJSON style propertieproperties names to Java Style CamelCase names with GSON

I'm using GsonGSON to convert jsonJSON data I get to a Java object. It works pretty well in all my tests. The problem is that our real objects have some properties named like is_online. GsonGSON only maps them if they are named totally equal, it would be nice to have GsonGSON convert the names to Java camel case isOnline.

It seems this is possible while creating the jsonJSON data, camel case is converted to underscore separated words in jsonJSON. But I can't find a way to specify this the other way round.

Convert Json style propertie names to Java Style CamelCase names with GSON

I'm using Gson to convert json data I get to a Java object. It works pretty well in all my tests. The problem is that our real objects have some properties named like is_online. Gson only maps them if they are named totally equal, it would be nice to have Gson convert the names to Java camel case isOnline.

It seems this is possible while creating the json data, camel case is converted to underscore separated words in json. But I can't find a way to specify this the other way round.

Convert JSON style properties names to Java CamelCase names with GSON

I'm using GSON to convert JSON data I get to a Java object. It works pretty well in all my tests. The problem is that our real objects have some properties named like is_online. GSON only maps them if they are named totally equal, it would be nice to have GSON convert the names to Java camel case isOnline.

It seems this is possible while creating the JSON data, camel case is converted to underscore separated words in JSON. But I can't find a way to specify this the other way round.

deleted 2 characters in body
Source Link
Janusz
  • 190k
  • 115
  • 306
  • 373

I'm using Gson to convert json data I get to a Java object. It works pretty well in all my tests. The problem is that I our real objects have some properties named like is_online. Gson only maps them if they are named totally equal, it would be nice to have Gson convert the names to Java camel case isOnline.

It seems this is possible while creating the json data, camel case is converted to underscore separated words in json. But I can't find a way to specify this the other way round.

I'm using Gson to convert json data I get to a Java object. It works pretty well in all my tests. The problem is that I our real objects have some properties named like is_online. Gson only maps them if they are named totally equal, it would be nice to have Gson convert the names to Java camel case isOnline.

It seems this is possible while creating the json data, camel case is converted to underscore separated words in json. But I can't find a way to specify this the other way round.

I'm using Gson to convert json data I get to a Java object. It works pretty well in all my tests. The problem is that our real objects have some properties named like is_online. Gson only maps them if they are named totally equal, it would be nice to have Gson convert the names to Java camel case isOnline.

It seems this is possible while creating the json data, camel case is converted to underscore separated words in json. But I can't find a way to specify this the other way round.

Source Link
Janusz
  • 190k
  • 115
  • 306
  • 373

Convert Json style propertie names to Java Style CamelCase names with GSON

I'm using Gson to convert json data I get to a Java object. It works pretty well in all my tests. The problem is that I our real objects have some properties named like is_online. Gson only maps them if they are named totally equal, it would be nice to have Gson convert the names to Java camel case isOnline.

It seems this is possible while creating the json data, camel case is converted to underscore separated words in json. But I can't find a way to specify this the other way round.