Parsing json with android

后端 未结 4 2029
日久生厌
日久生厌 2021-01-28 09:44

Hi I want to parse this json:

[{
    \"codError\": 0,
    \"msg\": \"OK\"
}, {
    \"id\": 1,
    \"role\": {
        \"id\": 4,
        \"name\": \"Super\",
            


        
4条回答
  •  无人共我
    2021-01-28 10:14

    Why should we do parsing of JSON if you are provided a ready made tool to parse a JSON and give you a complete hierarchy of Java classes???

    Right??

    Take a look at JsonSchema 2 Pojo site.

    Provide your JSON input/output there. Select appropriate options like

    Source type: JSON
    Annotation style: GSON

    Enable following 3 options

    1. Generate builder methods
    2. Use primitive types
    3. Use long integers

    Select Jar button and you are done with.

    Note

    Please validate your JSON first.

提交回复
热议问题