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

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

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

Json.fromJson介绍

暂无

代码示例

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

@VisibleForTesting
static TypedRecordUpdate parseChange(FormClass formClass, JsonValue changeObject, int userId) throws JsonMappingException {
  return parseChange(formClass, Json.fromJson(RecordUpdate.class, changeObject), userId);
}

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

public static <T> List<T> fromJsonArray(Class<T> componentClass, JsonValue array) throws JsonMappingException {
  List<T> list = new ArrayList<>();
  for (int i = 0; i < array.length(); i++) {
    list.add(Json.fromJson(componentClass, array.get(i)));
  }
  return list;
}

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

@Override
public Promise<FormSyncSet> getRecordVersionRange(String formId, long localVersion, final long toVersion, Optional<String> cursor) {
  String url = formUrl(formId) +
      "/records/versionRange" +
      "?localVersion=" + localVersion +
      "&version=" + toVersion;
  if(cursor.isPresent()) {
    url = url + "&cursor=" + cursor.get();
  }
  return get(url, value -> {
    try {
      return Json.fromJson(FormSyncSet.class, value);
    } catch (JsonMappingException e) {
      throw new RuntimeException(e);
    }
  });
}

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

private static Object fromArray(Class arrayType, JsonValue jsonArray) throws JsonMappingException {
  Class componentType = arrayType.getComponentType();
  Object array = Array.newInstance(componentType, jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    Array.set(array, i, Json.fromJson(componentType, jsonArray.get(i)));
  }
  return array;
}

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

/**
 * Get a Record's History
 *
 * @param formId Id of the Form
 * @param recordId Id of the record
 */
public Promise<RecordHistory> getRecordHistory(String formId, String recordId) {
  return get(recordUrl(formId, recordId) + "/history", jsonElement -> {
    try {
      return Json.fromJson(RecordHistory.class, jsonElement);
    } catch (JsonMappingException e) {
      throw new RuntimeException(e);
    }
  });
}

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

/**
 * Validates and executes a {@code ResourceUpdate} encoded as a json object. The object
 * must have a changes property that takes the value of an array. 
 *
 * @throws InvalidUpdateException if the given update
 * is not a validate update.
 */
public void execute(JsonValue transactionObject) {
  try {
    execute(Json.fromJson(RecordTransaction.class, transactionObject));
  } catch (JsonMappingException e) {
    throw new InvalidUpdateException(e);
  }
}

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

@Override
public Promise<Maybe<Analysis>> getAnalysis(String id) {
  return getRaw(baseUrl + "/analysis/" + id, response -> {
    switch (response.getStatusCode()) {
      case Response.SC_OK:
        try {
          return Maybe.of(Json.fromJson(Analysis.class, Json.parse(response.getText())));
        } catch (JsonMappingException e) {
          throw new RuntimeException(e);
        }
      case Response.SC_FORBIDDEN:
        return Maybe.forbidden();
      case Response.SC_NOT_FOUND:
        return Maybe.notFound();
      default:
        throw new ApiException(response.getStatusCode());
    }
  });
}

相关文章