我想将一个JSON
列表从一个活动发送到其他活动。我做这样无法在Android中获取JSON数据
要发送
List<JSONObject> jsonList = new ArrayList<JSONObject>();
Intent i = new Intent(getApplicationContext(), AdapterContent.class);
Bundle b = new Bundle();
b.putString("Array",jsonList.toString());
i.putExtras(b);
对于接受
Bundle b = getIntent().getExtras();
String Array=b.getString("Array");
Log.i("TAG" ,Array);
JSONObject jsonobj = new JSONObject(Array);
Log.i("Name" , String.valueOf(jsonobj.getString("Name")));
JSON对象
[
{"Name":"Area1"},
{"Name":"Area 2"}
]
但它促使
W/System.err的:在com.example.data.mydata.onCreate
它打印Array
但不是Name
从JsonObj
有什么不对吗?
使用jsonobj.get(“姓名”),也许这将有助于 –
你是什么jsonList? Json数组或Java数组? –
@MdAbdulGafur是对的。你在'jsonObj'中获得的格式是什么格式通过[pastie](http://pastie.org) – Praveenkumar