本文整理了Java中org.activityinfo.json.Json.stringify()
方法的一些代码示例,展示了Json.stringify()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.stringify()
方法的具体详情如下:
包路径:org.activityinfo.json.Json
类名称:Json
方法名:stringify
暂无
代码示例来源:origin: bedatadriven/activityinfo
@Override
public Promise<Void> updateAnalysis(AnalysisUpdate analysis) {
return post(RequestBuilder.POST, baseUrl + "/analysis", Json.stringify(analysis));
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public Promise<Void> updateRecords(RecordTransaction transaction) {
return post(RequestBuilder.POST, baseUrl + "/update", Json.stringify(transaction));
}
代码示例来源:origin: bedatadriven/activityinfo
public void testStringify() {
String json = "{\"a\":1,\"b\":\"hello\",\"c\":true,"
+ "\"d\":null,\"e\":[1,2,3,4],\"f\":{\"x\":1}}";
assertEquals(json, Json.stringify(Json.parse(json)));
}
代码示例来源: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));
}
//
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void testDatabaseMetadata() {
DatabaseProvider impl = injector.getInstance(DatabaseProvider.class);
UserDatabaseMeta metadata = impl.getDatabaseMetadata(CuidAdapter.databaseId(1), 1).get();
System.out.println(Json.stringify(metadata.toJson(), 4));
}
代码示例来源:origin: bedatadriven/activityinfo
public void save(CloseEvent.CloseHandler closeHandler) {
// If the view model is still loading, ignore this click
if(viewModel == null) {
return;
}
if(!viewModel.isValid()) {
invalidFeedback();
return;
}
// Good to go...
RecordTransaction tx = viewModel.buildTransaction();
LOGGER.info("Submitting transaction: " + Json.stringify(tx));
formStore.updateRecords(tx).then(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
MessageBox box = new MessageBox(I18N.CONSTANTS.serverError(), I18N.CONSTANTS.errorOnServer());
box.setModal(true);
box.show();
}
@Override
public void onSuccess(Void result) {
closeHandler.onClose(new CloseEvent(null));
}
});
}
代码示例来源:origin: bedatadriven/activityinfo
public void testStringifyCycle() {
String json = "{\"a\":1,\"b\":\"hello\",\"c\":true,"
+ "\"d\":null,\"e\":[1,2,3,4],\"f\":{\"x\":1}}";
JsonValue obj = parse(json);
obj.put("cycle", obj);
try {
Json.stringify(obj);
fail("Expected JsonException for object cycle");
} catch (Exception je) {
}
}
代码示例来源:origin: bedatadriven/activityinfo
public String getQueryPostBody() {
QueryModel queryModel = new QueryModel(tableModel.getFormId());
for (EffectiveTableColumn tableColumn : tableModel.getColumns()) {
List<ColumnModel> columns = tableColumn.getQueryModel();
if(columns.size() == 1) {
ColumnModel columnModel = new ColumnModel();
columnModel.setId(tableColumn.getLabel());
columnModel.setFormula(tableColumn.getFormulaString());
queryModel.addColumn(columnModel);
} else if(columns.size() > 1) {
for (int i = 0; i < columns.size(); i++) {
ColumnModel columnModel = new ColumnModel();
columnModel.setId(tableColumn.getLabel() + "." + i);
columnModel.setFormula(tableColumn.getFormulaString());
queryModel.addColumn(columnModel);
}
}
}
return Json.stringify(queryModel.toJson(), 2);
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void locationChange() throws SQLException {
MySqlRecordHistoryBuilder builder = new MySqlRecordHistoryBuilder(catalog);
RecordHistory array = builder.build(new RecordRef(
CuidAdapter.activityFormClass(33),
CuidAdapter.cuid(CuidAdapter.SITE_DOMAIN, 968196924)));
System.out.println(Json.stringify(Json.toJson(array), 2));
}
代码示例来源:origin: bedatadriven/activityinfo
public void testStringifyNonCycle() {
String json = "{\"a\":1,\"b\":\"hello\",\"c\":true,"
+ "\"d\":null,\"e\":[1,2,3,4],\"f\":{\"x\":1}}";
JsonValue obj = parse(json);
JsonValue obj2 = parse("{\"x\": 1, \"y\":2}");
obj.put("nocycle", obj2);
obj.put("nocycle2", obj2);
try {
Json.stringify(obj);
} catch (JsonException je) {
fail("JsonException for object cycle when none exists: " + je);
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void modelClass() throws IOException {
FormClass formClass = new FormClass(ResourceId.valueOf("FORM"));
formClass.setLabel("My Form");
formClass.addField(ResourceId.valueOf("F1"))
.setLabel("My field")
.setRequired(true)
.setType(TextType.SIMPLE)
.setCode("MY");
JaxRsJsonReader reader = new JaxRsJsonReader();
assertTrue(reader.isReadable(FormClass.class, FormClass.class,
new Annotation[0],
MediaType.APPLICATION_JSON_TYPE));
assertTrue(reader.isWriteable(FormClass.class, FormClass.class,
new Annotation[0],
MediaType.APPLICATION_JSON_TYPE));
ByteArrayOutputStream entity = new ByteArrayOutputStream();
reader.writeTo(formClass, formClass.getClass(), formClass.getClass(),
new Annotation[0],
MediaType.APPLICATION_JSON_TYPE,
EMPTY_HEADERS, entity);
JsonValue jsonObject = Json.parse(new String(entity.toByteArray(), Charsets.UTF_8));
System.out.println(Json.stringify(jsonObject));
FormClass reformClass = (FormClass) reader.readFrom((Class)FormClass.class, FormClass.class,
new Annotation[0],
MediaType.APPLICATION_JSON_TYPE,
EMPTY_HEADERS,
new ByteArrayInputStream(entity.toByteArray()));
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void testSubFormExport() {
IncidentForm incidentForm = setup.getCatalog().getIncidentForm();
TableModel tableModel = ImmutableTableModel.builder().formId(incidentForm.getFormId())
.addColumns(ImmutableTableColumn.builder()
.label("My PCODE")
.formula(IncidentForm.PROTECTION_CODE_FIELD_ID.asString())
.build())
.build();
TableViewModel viewModel = new TableViewModel(setup.getFormStore(), tableModel);
Observable<ExportViewModel> exportModel = viewModel.computeExportModel(
Observable.just(ReferralSubForm.FORM_ID),
Observable.just(ExportScope.SELECTED));
Connection<TableModel> exportModelConnection = setup.connect(exportModel.transform(ExportViewModel::getTableModel));
Connection<Boolean> columnLimitConnection = setup.connect(exportModel.transform(ExportViewModel::isColumnLimitExceeded));
System.out.println(Json.stringify(exportModelConnection.assertLoaded().toJson(), 2));
assertThat(exportModelConnection.assertLoaded().getFormId(), equalTo(ReferralSubForm.FORM_ID));
assertThat(exportModelConnection.assertLoaded().getColumns(), hasSize(3));
assertThat(columnLimitConnection.assertLoaded(), equalTo(false));
TableColumn firstColumn = exportModelConnection.assertLoaded().getColumns().get(0);
assertThat(firstColumn.getLabel(), equalTo(Optional.of("My PCODE")));
assertThat(firstColumn.getFormula(), equalTo(
new CompoundExpr(new SymbolNode(ColumnModel.PARENT_SYMBOL),
IncidentForm.PROTECTION_CODE_FIELD_ID).asExpression()));
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void testSubFormExportWithFilter() {
IncidentForm incidentForm = setup.getCatalog().getIncidentForm();
TableModel tableModel = ImmutableTableModel.builder().formId(incidentForm.getFormId())
.addColumns(ImmutableTableColumn.builder()
.label("My PCODE")
.formula(IncidentForm.PROTECTION_CODE_FIELD_ID.asString())
.build())
.filter(constructFilter())
.build();
TableViewModel viewModel = new TableViewModel(setup.getFormStore(), tableModel);
Connection<TableModel> exportModel = setup.connect(
viewModel.computeExportModel(
Observable.just(ReferralSubForm.FORM_ID),
Observable.just(ExportScope.SELECTED),
Observable.just(ExportScope.SELECTED),
Observable.just(ExportFormat.XLS))
.transform(ExportViewModel::getTableModel));
System.out.println(Json.stringify(exportModel.assertLoaded().toJson(), 2));
assertThat(exportModel.assertLoaded().getFormId(), equalTo(ReferralSubForm.FORM_ID));
assertThat(exportModel.assertLoaded().getColumns(), hasSize(3));
assertThat(exportModel.assertLoaded().getFilter(), equalTo(Optional.of(constructFilter())));
}
内容来源于网络,如有侵权,请联系作者删除!