0

I want to retrieve the value that is in the following from Json 'en' 'ja''de' & make a string.xml for the android with the acquired value does it taken out doing what from such nested JSON

`{                                            
  "resources": {                            
    "string": {
      "en": [
        {
          "name": "Parts",
          "character": "wheel"
        },
        {
          "name": "Box",
          "character": "container"
        },
        {
          "name": "ZentraleTeile",
          "character": "engine"
        },
        {
          "name": "Electric",
          "character": "battery"
        },
        {
          "name": "Kabel",
          "character": "flatcable"
        }
      ],
      "ja": [
        {
          "name": "Parts",
          "character": "ホイール"
        },
        {
          "name": "Box",
          "character": "コンテナ"
        },
        {
          "name": "ZentraleTeile",
          "character": "エンジン"
        },
        {
          "name": "Electric",
          "character": "バッテリー"
        },
        {
          "name": "Kabel",
          "character": "フラットケーブル"
        }
      ],
      "zh": [
        {
          "name": "Name",
          "character": "KOM指南2"
        },
        {
          "name": "Parts",
          "character": "轮"
        },
        {
          "name": "Box",
          "character": "集装箱"
        },
        {
          "name": "ZentraleTeile",
          "character": "发动机"
        },
        {
          "name": "Electric",
          "character": "电池"
        },
        {
          "name": "Kabel",
          "character": "扁平电缆"
        }
      ],
      "de": [
        {
        {
          "name": "Parts",
          "character": "Rad"
        },
        {
          "name": "Box",
          "character": "Container"
        },
        {
          "name": "ZentraleTeile",
          "character": "Motor"
        },
        {
          "name": "Electric",
          "character": "Batterie"
        },
        {
          "name": "Kabel",
          "character": "Flachbandkabel"
        }
      ]
    }
  }
}`

How can I easily do this with GSON and java?

SSM
  • 15
  • 4

1 Answers1

0

You'll have to use the JsonDeserializer that comes with GSON, to write your custom deserializer just go to the link:

https://sites.google.com/site/gson/gson-user-guide#TOC-Writing-a-Deserializer (present in Custom JSON deserializer using Gson)

Also check the existing stack overflow response because he has an example using the GsonBuilder, because you need to register the adapter.

Community
  • 1
  • 1
Deceiver
  • 324
  • 1
  • 2
  • 12