Search in sources :

Example 1 with JsonParser

use of org.activityinfo.json.JsonParser in project activityinfo by bedatadriven.

the class FormClassTest method parseResource.

private FormClass parseResource() throws IOException {
    URL resource = Resources.getResource(FormClass.class, "OldFormClass1.json");
    String json = Resources.toString(resource, Charsets.UTF_8);
    JsonParser parser = new org.activityinfo.json.JsonParser();
    JsonValue element = parser.parse(json);
    return FormClass.fromJson(element);
}
Also used : JsonValue(org.activityinfo.json.JsonValue) URL(java.net.URL) JsonParser(org.activityinfo.json.JsonParser)

Example 2 with JsonParser

use of org.activityinfo.json.JsonParser in project activityinfo by bedatadriven.

the class ActivityPolicy method updateFormClass.

private void updateFormClass(Activity activity, String name, String json) {
    if (!Strings.isNullOrEmpty(json)) {
        JsonParser parser = new JsonParser();
        JsonValue jsonObject = parser.parse(json);
        FormClass formClass = FormClass.fromJson(jsonObject);
        formClass.setLabel(name);
        String updatedJson = formClass.toJsonString();
        JsonHelper.updateWithJson(activity, updatedJson);
    }
}
Also used : FormClass(org.activityinfo.model.form.FormClass) JsonValue(org.activityinfo.json.JsonValue) JsonParser(org.activityinfo.json.JsonParser)

Aggregations

JsonParser (org.activityinfo.json.JsonParser)2 JsonValue (org.activityinfo.json.JsonValue)2 URL (java.net.URL)1 FormClass (org.activityinfo.model.form.FormClass)1