简体   繁体   English

如何使用 gson 解析 json ?

[英]How to parse json using gson ?

我怎样才能得到这个 json 的时间或文本http://www.mocky.io/v2/58889af52600007c1d966456有人可以帮助我???

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").toString();
  return result;
} //jsonLine refer to json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM