【发布时间】:2018-12-26 07:35:02
【问题描述】:
我有一个 JSONObject 包含一个简单的 json 文档(不包含嵌套对象或 JSONArray)。我想打印那些数据。
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
}
}
假设输入是{fname:"Stack", lname:"Overflow"},那么输出应该是:-
fname => Stack
lname => Overflow
如果输入是{country:"India", city:"Delhi"}那么输出应该是:-
country => India
city => Delhi
你能帮我怎么做吗?
【问题讨论】: