安卓 java [{"sip":[{"sip":"34463","uuid":"4dm0217817000361"}]}] 如何获取 sip 和uuid值
时间: 2024-01-01 09:06:53 浏览: 29
Data-UUID-0.14.tar.gz_Data::uuid_uuid
根据提供的引用内容,您可以使用Java的JSONObject类来解析JSON数据并获取sip和uuid值。下面是一个示例代码:
```java
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Main {
public static void main(String[] args) {
String jsonStr = "[{\"sip\":[{\"sip\":\"34463\",\"uuid\":\"4dm0217817000361\"}]}]";
try {
JSONArray jsonArray = new JSONArray(jsonStr);
JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONArray sipArray = jsonObject.getJSONArray("sip");
JSONObject sipObject = sipArray.getJSONObject(0);
String sipValue = sipObject.getString("sip");
String uuidValue = sipObject.getString("uuid");
System.out.println("sip value: " + sipValue);
System.out.println("uuid value: " + uuidValue);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
```
输出结果:
```
sip value: 34463
uuid value: 4dm0217817000361
```
阅读全文