org.activityinfo.json.Json.create()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.activityinfo.json.Json.create()方法的一些代码示例,展示了Json.create()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.create()方法的具体详情如下:
包路径:org.activityinfo.json.Json
类名称:Json
方法名:create

Json.create介绍

暂无

代码示例

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  return Json.create(year);
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  if(Double.isNaN(value)) {
    return Json.createNull();
  } else {
    return Json.create(value);
  }
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue getParametersAsJson() {
  JsonValue object = createObject();
  object.put("formId", classId == null ? Json.createNull(): Json.create(classId.asString()));
  return object;
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  if(valueIds.isEmpty()) {
    return Json.createNull();
  } else if(valueIds.size() == 1) {
    return Json.create(valueIds.iterator().next().asString());
  } else {
    JsonValue array = Json.createArray();
    for (ResourceId valueId : valueIds) {
      array.add(Json.create(valueId.asString()));
    }
    return array;
  }
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  if(prefix == null) {
    return Json.create(number);
  } else {
    JsonValue object = createObject();
    object.put("prefix", prefix);
    object.put("number", number);
    return object;
  }
}

代码示例来源:origin: bedatadriven/activityinfo

private JsonValue toJson(Set<ResourceId> offlineForms) {
  JsonValue array = Json.createArray();
  for (ResourceId offlineForm : offlineForms) {
    array.add(Json.create(offlineForm.asString()));
  }
  return array;
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  JsonValue object = Json.createObject();
  object.put("operation", operation.name());
  object.put("permitted", permitted);
  object.add("filter", filter.isPresent() ? Json.create(filter.get()) : Json.createNull());
  return object;
}

代码示例来源:origin: bedatadriven/activityinfo

public void testZero() {
 JsonValue zero = Json.create(0);
 assertTrue(zero.isNumber());
 assertTrue(zero.isJsonPrimitive());
 assertFalse(zero.isJsonNull());
 JsonValue object = Json.createObject();
 object.put("zero", zero);
 assertEquals(0.0, object.getNumber("zero"));
 assertTrue(object.get("zero").isNumber());
 assertFalse(object.get("zero").isJsonNull());
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  return Json.create(text);
}

代码示例来源:origin: bedatadriven/activityinfo

/**
 * Sets the deleted.
 *
 * @param deleted True if the record should be deleted
 */
public FormRecordUpdateBuilder setDeleted(boolean deleted) {
  this.jsonObject.put("deleted", Json.create(deleted));
  return this;
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  return Json.create(toString());
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  return Json.create(toString());
}

代码示例来源:origin: bedatadriven/activityinfo

@Override
public JsonValue toJson() {
  return Json.create(asBoolean());
}

代码示例来源:origin: bedatadriven/activityinfo

@JsOverlay
public void setFieldValue(String fieldId, double value) {
  setFieldValue(fieldId, Json.create(value));
}

代码示例来源:origin: bedatadriven/activityinfo

@JsOverlay
public void setFieldValue(String fieldId, String value) {
  setFieldValue(fieldId, Json.create(value));
}

代码示例来源:origin: bedatadriven/activityinfo

public void toBeFixedTestZeroNull() {
 JsonValue one = Json.create(1);
 JsonValue zero = Json.create(0);
 // GWT is compiling both expressions "one == null" and "zero == null" to
 // "one" and "zero" respectively. Somewhere there is an assumption that
 // if a value of interface type points to a JavaScript object, then we can rely
 // on an implicit conversion from object to boolean, which is equivalent to (object != null)
 // But this DOESN'T work if Json.create() returns an unboxed JS number.
 // In this case, a zero value will also be implicitly converted to a FALSE boolean value.
 assertFalse("one", one == null);
 assertFalse("zero", zero == null);
}

代码示例来源:origin: bedatadriven/activityinfo

public void testSerializeBoolean() throws Exception {
 assertJsonEqualsAfterSerialization(Json.create(true));
 assertJsonEqualsAfterSerialization(Json.create(false));
}

代码示例来源:origin: bedatadriven/activityinfo

public void testSerializeNumber() throws Exception {
 assertJsonEqualsAfterSerialization(Json.create(0));
 assertJsonEqualsAfterSerialization(Json.create(-1.213123123));
}

代码示例来源:origin: bedatadriven/activityinfo

public void testBooleanTypes() {
 JsonValue booleanValue = Json.create(true);
 assertEquals(JsonType.BOOLEAN, booleanValue.getType());
 JsonValue doubleValue = Json.create(1.5);
 assertEquals(JsonType.NUMBER, doubleValue.getType());
}

代码示例来源:origin: bedatadriven/activityinfo

public void testStringifyDoubleNanInfinity() {
  JsonValue json = Json.create(Double.NaN);
  assertEquals("null",Json.stringify(json));
  json = Json.create(Double.POSITIVE_INFINITY);
  assertEquals("null",Json.stringify(json));
  json = Json.create(Double.NEGATIVE_INFINITY);
  assertEquals("null",Json.stringify(json));
 }
//

相关文章