Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android studio json parser

/*
if respond is object
respond = { "a": "a", "b" : [1,2] }
*/
JSONObject jo = new JSONObject(respond); 

String a = jo.getString("a"); // a
JSONArray ja2 = jo.getJSONArray("b"); // [1,2]
int one = ja2.getInt(0) // 1
Comment

android studio json parser

/*
if respond is array
respond = [ {"a": "a", "b" : [1,2] } ]
*/
JSONArray ja1 = new JSONArray(respond);
JSONObject jo= ja1.getJSONObject(0); // {"a": "a", "b" : [1,2] }

String a = jo.getString("a"); // a
JSONArray ja2 = jo.getJSONArray("b"); // [1,2]
Comment

PREVIOUS NEXT
Code Example
Java :: java jre 
Java :: javaparser 
Java :: Create EntityManager Hibernate 
Java :: java long data type 
Java :: return random boolean 
Java :: marshalling in java 
Java :: how to sort the arraylist without changing the original arraylist 
Java :: java list of lists 
Java :: how to get string value in java in android 
Java :: hashmap put method 
Java :: one line hashmap java 
Java :: java nested static class 
Java :: java double 
Java :: how to change datatypes in java 
Java :: java string util if empty default 
Java :: how to multiply a number by itself using for loop in java 
Java :: java check prime number 
Java :: JAVA Multi-line Comment 
Java :: get image file path 
Java :: binary to string java 
Java :: how to read space separated integers in java 
Java :: java return pair 
Java :: switch java 
Java :: java constructor example 
Java :: valid parentheses leetcode solution java 
Java :: types of exception in java 
Java :: java meeting scheduler 
Java :: jdsu software download 
Java :: receive an int from terminal java 
Java :: what is a callable in java 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =