Samadhan Medge
Samadhan Medge

Reputation: 2049

JSONArray return null while parsing

I want to parse this JSON String :

{
  lhs: "1 British pound",
  rhs: "1.6152 U.S. dollars",
  error: "",
  icc: true
}

but JSONArray returns null value.

Upvotes: 1

Views: 598

Answers (1)

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132972

current json string contain an jsonObject instead of JsonArray so parse it as :

// Convert String to Json Object
JSONObject jsonObject = new JSONObject("Pass_Your_Json_String");

// get lhs 
String str_lhs=jsonObject.getString("lhs");

// get rhs
String str_rhs=jsonObject.getString("rhs");

  //.....

Upvotes: 3

Related Questions