List of usage examples for com.fasterxml.jackson.databind JsonNode toString
public abstract String toString();
From source file:com.redhat.lightblue.eval.ArrayRangeProjectorTest.java
@Test public void one_$parent_array_range_projection_with_no_match_returns_empty_node() throws Exception { Projection p = EvalTestContext/*from w ww .j ava2 s. c o m*/ .projectionFromJson("{'field':'field6.$parent.field7','range':[5,6],'project':{'field':'elemf3'}}"); Projector projector = Projector.getInstance(p, md); JsonNode expectedNode = JsonUtils.json("{}".replace('\'', '\"')); JsonDoc pdoc = projector.project(jsonDoc, JSON_NODE_FACTORY); Assert.assertEquals(expectedNode.toString(), pdoc.toString()); }
From source file:com.redhat.lightblue.eval.ArrayRangeProjectorTest.java
@Test public void two_$parent_array_range_projection_with_no_match_returns_empty_node() throws Exception { Projection p = EvalTestContext.projectionFromJson( "{'field':'field6.nf7.$parent.$parent.field7','range':[5,6],'project':{'field':'elemf3'}}"); Projector projector = Projector.getInstance(p, md); JsonNode expectedNode = JsonUtils.json("{}".replace('\'', '\"')); JsonDoc pdoc = projector.project(jsonDoc, JSON_NODE_FACTORY); Assert.assertEquals(expectedNode.toString(), pdoc.toString()); }
From source file:com.redhat.lightblue.crud.ldap.ITCaseLdapCRUDController_WithProperties_Test.java
@Test public void test1CustomerInsertWithProperties() throws Exception { Response response = lightblueFactory.getMediator().insert( createRequest_FromResource(InsertionRequest.class, "./crud/insert/customer-insert-single.json")); assertNotNull(response);/*from w w w . ja v a2 s.c o m*/ assertNoErrors(response); assertNoDataErrors(response); assertEquals(1, response.getModifiedCount()); JsonNode entityData = response.getEntityData(); assertNotNull(entityData); JSONAssert.assertEquals("[{\"id\":\"uid=frodo.baggins," + BASEDB_CUSTOMERS + "\"}]", entityData.toString(), false); }
From source file:io.wcm.caravan.pipeline.extensions.hal.filter.ReportHalResourceFiltersTest.java
@Test public void report_shouldCopyTheJsonNodeHavingAnError() { input.getModel().put("att1", "value").putObject("att2").put("att3", "value3"); Mockito.when(delegate1.apply(HAL_PATH, input)).thenReturn(false); ReportHalResourceFilters.report(report, delegate1).apply(HAL_PATH, input); JsonNode copy = report.getEmbedded("item").get(0).getModel().get("copy"); assertEquals(input.getModel().toString(), copy.toString()); input.getModel().remove("att1"); assertNotEquals(input.getModel().toString(), copy.toString()); }
From source file:io.wcm.caravan.pipeline.extensions.hal.filter.ReportHalResourceFiltersTest.java
@Test public void all_shouldCopyTheJsonNodeHavingAnError() { input.getModel().put("att1", "value").putObject("att2").put("att3", "value3"); Mockito.when(delegate1.apply(HAL_PATH, input)).thenReturn(false); ReportHalResourceFilters.all(report, delegate1, delegate2).apply(HAL_PATH, input); JsonNode copy = report.getEmbedded("item").get(0).getModel().get("copy"); assertEquals(input.getModel().toString(), copy.toString()); input.getModel().remove("att1"); assertNotEquals(input.getModel().toString(), copy.toString()); }
From source file:com.redhat.lightblue.metadata.types.StringType.java
@Override public Object fromJson(JsonNode node) { if (node.isValueNode()) { return node.asText(); } else {//from w ww .j a v a 2 s.c o m throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString()); } }
From source file:com.servioticy.api.commons.data.Subscription.java
/** Generate response to getting a SO * * @return String/*from w w w .j av a 2s. c o m*/ */ public String responseGetSO() { JsonNode root = subsRoot; ((ObjectNode) root).remove("userId"); return root.toString(); }
From source file:org.wikidata.couchbase.MongoPersistHandler.java
@Override public void save(Integer id, String jsonString) { DBObject dbObject = null;//w ww . j av a 2s .co m try { dbObject = new BasicDBObject(); JsonNode node = createJsonNode(jsonString); JsonNode transformedNode = transformNode(node); String jsonText = transformedNode.toString(); dbObject.put("item", JSON.parse(jsonText)); String idString = buildDocumentKey(id); dbObject.put("_id", idString); getCollection().insert(dbObject); } catch (MongoException.DuplicateKey e) { LOG.info("Item " + id + " exists and is updated"); if (LOG.isDebugEnabled()) { LOG.debug("Stacktrace: ", e); } getCollection().save(dbObject); } catch (Exception e) { LOG.error("Error while saving Object.", e); throw new RuntimeException("Error while saving Object.", e); } }
From source file:org.dd4t.contentmodel.impl.FieldSetImpl.java
@JsonAnySetter public void set(String fieldKey, JsonNode embeddedField) { try {/* w w w. j a va 2 s . c om*/ // The basefield annotations will map the fields to concrete types BaseField b = JsonDataBinder.getGenericMapper().readValue(embeddedField.toString(), BaseField.class); content.put(fieldKey, b); } catch (IOException e) { LOG.error("Error deserializing FieldSet.", e); } rawContent.put(fieldKey, embeddedField); }
From source file:org.camunda.spin.impl.json.jackson.JacksonJsonLogger.java
public SpinJsonException unableToDeserialize(JsonNode jsonNode, JavaType type, Exception cause) { return new SpinJsonException(exceptionMessage("006", "Cannot deserialize '{}...' to java type '{}'", jsonNode.toString().substring(0, 10), type), cause); }