google / google/gson

Parse nested json into flat model class objects

Open
#2,555 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

# Problem solved by the feature
No need of creating nested classes according to the json file.

# Feature description
if i have a nested json like :
{ id : 1 ,
name : "myname" ,
address : {
street : "my lane" ,
city : "mycity" }
}
I want to parse this json into target model class but cannot parse without creating nested class 'address' inside my target class.
There should be a method to write like @Serialized("address.street") in model class field which automatically get the nested street value from address so that i do not need to create a nested class in order to parse this json into object .
Target model class will be Model> id, name, street, city

# Alternatives / workarounds
alternative is simply create nested class Model> id , name, Address> street, city

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.