Here you can find the source of getValueFromJson(JsonObject currentJsonObject, String key)
public static String getValueFromJson(JsonObject currentJsonObject, String key)
//package com.java2s; //License from project: Apache License import javax.json.JsonObject; public class Main { public static String getValueFromJson(JsonObject currentJsonObject, String key) { String result = ""; if (currentJsonObject.containsKey(key)) { switch (currentJsonObject.get(key).getValueType()) { case STRING: result = currentJsonObject.getString(key); break; case NUMBER: result = String.valueOf(currentJsonObject.getInt(key)); break; case NULL: result = ""; break; }/*from w w w. j av a 2 s. c om*/ } return result; } }