-4

Hello I have the JSON given below, how i can retrieve data by passing parameters into method given in (for android) :

JSON:

{
  "transport": "POST",
  "envelope": "JSON-RPC-2.0",
  "contentType": "application\/json",
  "SMDVersion": "2.0",
  "target": "\/index.php",
  "services": {
    "search": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "array",
          "name": "criterias",
          "optional": false
        }
      ],
      "returns": "array"
    },
    "getDayConferences": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "integer",
          "name": "nb_day",
          "optional": false
        }
      ],
      "returns": "array"
    },
    "getParticipants": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [

      ],
      "returns": "array"
    },
    "getAllForLocation": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "float",
          "name": "latitude",
          "optional": false
        },
        {
          "type": "float",
          "name": "longitude",
          "optional": false
        }
      ],
      "returns": "array"
    }
  },
  "methods": {
    "search": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "array",
          "name": "criterias",
          "optional": false
        }
      ],
      "returns": "array"
    },
    "getDayConferences": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "integer",
          "name": "nb_day",
          "optional": false
        }
      ],
      "returns": "array"
    },
    "getParticipants": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [

      ],
      "returns": "array"
    },
    "getAllForLocation": {
      "envelope": "JSON-RPC-2.0",
      "transport": "POST",
      "parameters": [
        {
          "type": "float",
          "name": "latitude",
          "optional": false
        },
        {
          "type": "float",
          "name": "longitude",
          "optional": false
        }
      ],
      "returns": "array"
    }
  }
}

Thank you in advance for help..

Bhavik Tikudiya
  • 103
  • 1
  • 7
  • try to use GSON library or refer this to parse response yourself- see here=> http://stackoverflow.com/a/5581922/1225413 – Akhil Jain Jan 10 '14 at 08:24
  • I have seen some examples but the problem is in that data from json is straight forward. In the JSON data posted by me i have functions like searc, getDayConference etc whihc i need to call to get data. I am confussed. – Bhavik Tikudiya Jan 10 '14 at 12:06

2 Answers2

0

Well, the most straightforward solution is to use JsonReader if you dont mind writting a lot of code.

However, you can try to look for some utils that provide mapping Json data to the POJO.

P.S. Please try to make some research before posting the question to StackOverflow.

Community
  • 1
  • 1
ivstas
  • 1,203
  • 1
  • 16
  • 31
  • I have done some search but couldn't find any source or example which shows how to get data from this type of JSON. thnks for for your reply. – Bhavik Tikudiya Jan 10 '14 at 11:49
0
  1. You need to get data from network first, I suggest to use Volley network library for that. https://developers.google.com/live/shows/474338138

  2. You can use GSON library to parse json data to object. http://code.google.com/p/google-gson/

That's all

Orhan Obut
  • 8,756
  • 5
  • 32
  • 42