當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonValue類代碼示例

本文整理匯總了Java中com.eclipsesource.json.JsonValue的典型用法代碼示例。如果您正苦於以下問題:Java JsonValue類的具體用法?Java JsonValue怎麽用?Java JsonValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonValue類屬於com.eclipsesource.json包,在下文中一共展示了JsonValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getArrayString

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
public static ArrayList<String> getArrayString(JsonArray jsonArray)
{
    ArrayList<String> data = new ArrayList<String>();
    
    for (JsonValue jsonValue : jsonArray)
    {
        
        data.add(
                isNumeric(jsonValue.toString()) ? jsonValue.toString() :
                    jsonValue.asString()
                );
    }
    
    return data;
    
}
 
開發者ID:rodrigoEclipsa,項目名稱:excelToApp,代碼行數:17,代碼來源:GeneralUtil.java

示例2: testSingleSubjectKeyConfig

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
/**
 * Tests the result of the rest api single subject key GET when
 * there is a config.
 */
@Test
public void testSingleSubjectKeyConfig() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response = wt.path("network/configuration/devices").request().get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(1));

    JsonValue device1 = result.asObject().get("device1");
    Assert.assertThat(device1, notNullValue());

    JsonValue basic = device1.asObject().get("basic");
    Assert.assertThat(basic, notNullValue());

    checkBasicAttributes(basic);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:NetworkConfigWebResourceTest.java

示例3: load

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
private static Multimap<JsonStage, JsonValue> load(Map<String, FileHandle> map) throws IOException {
 try {
  Multimap<JsonStage, JsonValue> m = new Multimap<JsonStage, JsonValue>();
  for (Map.Entry<String, FileHandle> entry : map.entrySet()) {
    JsonStage stage = null;
    if (entry.getKey().startsWith("block")) {
      stage = JsonStage.BLOCK;
    } else if (entry.getKey().startsWith("item")) {
      stage = JsonStage.ITEM;
    } else if (entry.getKey().startsWith("recipe")) {
      stage = JsonStage.RECIPE;
    } else {
      throw new CubesException("Invalid json file path \"" + entry.getKey() + "\"");
    }

    Reader reader = entry.getValue().reader();
  
      m.put(stage, Json.parse(reader));
    } 
  }finally {
      reader.close();
    }
  return m;
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:25,代碼來源:JsonLoader.java

示例4: testSingleSubjectConfig

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
/**
 * Tests the result of the rest api single subject GET when
 * there is a config.
 */
@Test
public void testSingleSubjectConfig() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response =
            wt.path("network/configuration/devices/device1")
                    .request()
                    .get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(1));

    JsonValue basic = result.asObject().get("basic");
    Assert.assertThat(basic, notNullValue());

    checkBasicAttributes(basic);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:NetworkConfigWebResourceTest.java

示例5: testConfigs

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
/**
 * Tests the result of the rest api GET when there is a config.
 */
@Test
public void testConfigs() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response = wt.path("network/configuration").request().get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(2));

    JsonValue devices = result.get("devices");
    Assert.assertThat(devices, notNullValue());

    JsonValue device1 = devices.asObject().get("device1");
    Assert.assertThat(device1, notNullValue());

    JsonValue basic = device1.asObject().get("basic");
    Assert.assertThat(basic, notNullValue());

    checkBasicAttributes(basic);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:NetworkConfigWebResourceTest.java

示例6: getSuccessfulOperationTXID

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
public synchronized String getSuccessfulOperationTXID(String opID)
       throws WalletCallException, IOException, InterruptedException
{
    String TXID = null;
    JsonArray response = this.executeCommandAndGetJsonArray(
        "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
    JsonObject jsonStatus = response.get(0).asObject();
    JsonValue  opResultValue = jsonStatus.get("result"); 
    
    if (opResultValue != null)
    {
        JsonObject opResult = opResultValue.asObject();
        if (opResult.get("txid") != null)
        {
            TXID = opResult.get("txid").asString();
        }
    }
    
    return TXID;
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:21,代碼來源:ZCashClientCaller.java

示例7: executeCommandAndGetJsonValue

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
private JsonValue executeCommandAndGetJsonValue(String command1, String command2, String command3)
    throws WalletCallException, IOException, InterruptedException
{
    String strResponse = this.executeCommandAndGetSingleStringResponse(command1, command2, command3);

    JsonValue response = null;
    try
    {
      	response = Json.parse(strResponse);
    } catch (ParseException pe)
    {
      	throw new WalletCallException(strResponse + "\n" + pe.getMessage() + "\n", pe);
    }

    return response;
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:17,代碼來源:ZCashClientCaller.java

示例8: decomposeJSONValue

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
private void decomposeJSONValue(String name, JsonValue val, Map<String, String> map)
{
    if (val.isObject())
    {
        JsonObject obj = val.asObject();
        for (String memberName : obj.names())
        {
            this.decomposeJSONValue(name + "." + memberName, obj.get(memberName), map);
        }
    } else if (val.isArray())
    {
        JsonArray arr = val.asArray();
        for (int i = 0; i < arr.size(); i++)
        {
            this.decomposeJSONValue(name + "[" + i + "]", arr.get(i), map);
        }
    } else
    {
        map.put(name, val.toString());
    }
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:22,代碼來源:ZCashClientCaller.java

示例9: doPost

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
@Override
public ModelAndView doPost(IHTTPSession session) {
    JsonValue request = Json.parse(WebServer.getRequestBody(session));
    if (!request.isObject()) {
        return new BadRequest("expected object");
    }
    ValidationResult errors = new ValidationResult();
    String username = ((JsonObject) request).getString("username", null);
    if (username == null || username.trim().length() == 0) {
        errors.put("username", "Cannot be empty");
    }
    if (!errors.isEmpty()) {
        LOG.info("unable to save: " + errors);
        return new BadRequest(errors);
    }
    auth.resetPassword(username);
    return new Success();
}
 
開發者ID:dernasherbrezon,項目名稱:r2cloud,代碼行數:19,代碼來源:Restore.java

示例10: doPost

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
@Override
public ModelAndView doPost(IHTTPSession session) {
    JsonValue request = Json.parse(WebServer.getRequestBody(session));
    if (!request.isObject()) {
        return new BadRequest("expected object");
    }
    ValidationResult errors = new ValidationResult();
    Double lat = WebServer.getDouble(request, "lat");
    Double lon = WebServer.getDouble(request, "lng");
    if (lat == null) {
        errors.put("lat", "Cannot be empty");
    }
    if (lon == null) {
        errors.put("lng", "Cannot be empty");
    }
    if (!errors.isEmpty()) {
        LOG.info("unable to save: " + errors);
        return new BadRequest(errors);
    }
    autoUpdate.setEnabled(WebServer.getBoolean(request, "autoUpdate"));
    config.setProperty("locaiton.lat", String.valueOf(lat));
    config.setProperty("locaiton.lon", String.valueOf(lon));
    config.update();
    return new Success();
}
 
開發者ID:dernasherbrezon,項目名稱:r2cloud,代碼行數:26,代碼來源:General.java

示例11: parse

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
@Override
protected Object parse(Class<?> type, JsonValue value) {
    if (type.equals(Map.class)) {
        // Construct new map
        Map<String, List<AbstractInsnNode>> temp = new HashMap<>();
        // For each entry stored in the passes value
        value.asObject().forEach(m -> {
            // Extract block name and opcode list.
            // Put results into map.
            String name = m.getName();
            JsonArray opcodes = m.getValue().asArray();
            List<AbstractInsnNode> opcodeList = new ArrayList<>();
            for (JsonValue entry : opcodes.values()) {
                opcodeList.add(parse(entry.asObject()));
            }
            temp.put(name, opcodeList);
        });
        return temp;
    }
    return super.parse(type, value);
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:22,代碼來源:ConfBlocks.java

示例12: load

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
private static Multimap<JsonStage, JsonValue> load(Map<String, FileHandle> map) throws IOException {
  Multimap<JsonStage, JsonValue> m = new Multimap<JsonStage, JsonValue>();
  for (Map.Entry<String, FileHandle> entry : map.entrySet()) {
    JsonStage stage = null;
    if (entry.getKey().startsWith("block")) {
      stage = JsonStage.BLOCK;
    } else if (entry.getKey().startsWith("item")) {
      stage = JsonStage.ITEM;
    } else if (entry.getKey().startsWith("recipe")) {
      stage = JsonStage.RECIPE;
    } else {
      throw new CubesException("Invalid json file path \"" + entry.getKey() + "\"");
    }

    Reader reader = entry.getValue().reader();
    try {
      m.put(stage, Json.parse(reader));
    } finally {
      reader.close();
    }
  }
  return m;
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:24,代碼來源:JsonLoader.java

示例13: fromId

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
/**
 * Get strawpoll from its ID
 * @param id ID to lookup
 * @return Strawpoll Object
 * @throws IOException Strawpoll.me is down or denied our API access
 */
public static StrawpollObject fromId(int id) throws IOException {
    JsonValue jv = Util.jsonFromUrl(BASE_API + "/" + id);
    JsonObject jo = jv.asObject();
    String title = jo.getString("title", "title");
    boolean multiVote = jo.getBoolean("multi", false);

    JsonArray jOptions = jo.get("options").asArray();
    String[] options = new String[jOptions.size()];
    JsonArray jVotes = jo.get("votes").asArray();
    int[] votes = new int[jVotes.size()];
    for(int i = 0; i < options.length; i++) {
        options[i] = jOptions.get(i).asString();
        votes[i] = jVotes.get(i).asInt();
    }
    return new StrawpollObject(title, multiVote, options, votes);
}
 
開發者ID:paul-io,項目名稱:momo-2,代碼行數:23,代碼來源:StrawpollObject.java

示例14: parseStack

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
public static ItemStack parseStack(JsonValue js) {
    if (js.isString()) {
        return new ItemStack(getItem(js.asString()));
    } else if (js.isObject()) {
        JsonObject obj = js.asObject();
        JsonValue id = obj.get("id");
        if (id == null)
            throw new JsonException("No id");
        return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
    } else if (js.isNull()) {
        return null;
    }
    throw new JsonException("Invalid type " + js.toString());
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:15,代碼來源:RecipeJson.java

示例15: addItem

import com.eclipsesource.json.JsonValue; //導入依賴的package包/類
public static void addItem(JsonObject js) {
    if (js.get("tool") != null) {
        addItemTool(js);
        return;
    }
    String id = json.getString("id", null);
    if (id == null)
        throw new JsonException("No item id");
    JItem item = new JItem(id);

    JsonValue prop;

    prop = js.get("texture");
    if (prop != null) {
        item.textureString = prop.asString();
    } else {
        item.textureString = id;
    }

    for (JsonObject.Member member : js) {
        switch (member.getName()) {
        case "id":
        case "texture":
            break;
        default:
            throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
        }
    }

    IDManager.register(item);
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:32,代碼來源:ItemJson.java


注:本文中的com.eclipsesource.json.JsonValue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。