-2
{
  "widget": {
    "debug": "on",
    "window": {
      "title": "Sample Konfabulator Widget",
      "name": "main_window",
      "width": 500,
      "height": 500
    },
    "image": {
      "src": "Images/Sun.png",
      "name": "sun1",
      "hOffset": 250,
      "vOffset": 250,
      "alignment": "center"
    },
    "text": {
      "data": "Click Here",
      "size": 36,
      "style": "bold",
      "name": "text1",
      "hOffset": 250,
      "vOffset": 100,
      "alignment": "center",
      "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
    }
  }
}
Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105

2 Answers2

0

First, create your Models to parsing this JSON array. you can use JsonUtils and other JSON online tools to generate your models.

Then you have to use some tools to parsing (deserialize) JSON into your models. GSON is one of this tools. finally, you can get your data from your models and set them into the views.

FarshidABZ
  • 3,860
  • 4
  • 32
  • 63
0

Here you have a JSON object array so first you have to get the widget JSON object and then from the tag(value) of "window" get the inner JSON array. from that get the other objects.

{ "widget": 
{ "debug": "on", 
"window": 
    { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, 
"image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" },
"text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } 
} 
}

Refer a tutorial on how to manipulate JSON objects in Android.

have fun coding.

Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105
Tharusha
  • 635
  • 8
  • 25