I have a JSONObject
consisting of a simple json document(doesn't consists nested objects or JSONArray
). I want to print that data.
import org.json.JSONObject;
import java.util.Scanner;
public class Test2{
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
String s=scan.nextLine();
JSONObject j=new JSONObject(s);
// What code should I write here
}
}
Let us say if the input is {fname:"Stack", lname:"Overflow"}
then the output should be:-
fname => Stack
lname => Overflow
If the input is {country:"India", city:"Delhi"}
then the output should be:-
country => India
city => Delhi
Can you please help me how I can do it.