0

I have this use case where in I would need to dynamically create java objects out of json input and insert the data into sql tables.

I tried using gson APIs but unfortunately we need to specify strucuture of that class (Car.class). Is it possible to dynamically achieve the above use without having to specify the structure of the class(Car.class)

Gson gson = new Gson();

Car car = gson.fromJson(json, Car.class);

Thanks in advance

2
Contributors
1
Reply
17
Views
2 Months
Discussion Span
Last Post by Tarek_2
0

Hi,

I highly doubt it's possible. If we don't know the class structure than we can't use it after parsing.

I have seen (in Groovy) examples where the JSON object is converted into a map and you can, after that, get all keys and values easily.

I have found some examples with Jackson here.

Good luck.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.