Android 上使用 JSON
Gson
- Gson - javadoc https://www.javadoc.io/doc/com.google.code.gson/gson
Gson 解析 JSON
1 2 3 4 5 6 7 8 9 | public String parse(String jsonLine) { JsonElement jelement = new JsonParser().parse(jsonLine); JsonObject jobject = jelement.getAsJsonObject(); jobject = jobject.getAsJsonObject("data"); JsonArray jarray = jobject.getAsJsonArray("translations"); jobject = jarray.get(0).getAsJsonObject(); String result = jobject.get("translatedText").getAsString(); return result; } |