Codota Logo
ObjectNode
Code IndexAdd Codota to your IDE (free)

How to use
ObjectNode
in
org.codehaus.jackson.node

Best Java code snippets using org.codehaus.jackson.node.ObjectNode (Showing top 20 results out of 909)

Refine searchRefine arrow

  • JsonNode
  • JsonNodeFactory
  • ObjectMapper
  • ArrayNode
  • Common ways to obtain ObjectNode
private void myMethod () {
ObjectNode o =
  • Codota IconJsonNodeFactory instance;instance.objectNode()
  • Codota IconObjectMapper mapper;mapper.createObjectNode()
  • Codota IconArrayNode arrayNode;arrayNode.addObject()
  • Smart code suggestions by Codota
}
origin: kaaproject/kaa

String fqn = null;
ObjectNode object = new ObjectMapper().readValue(body, ObjectNode.class);
if (!object.has(TYPE) || !object.get(TYPE).isTextual()
  || !object.get(TYPE).getTextValue().equals("record")) {
 throw new IllegalArgumentException("The data provided is not a record!");
if (!object.has(NAMESPACE) || !object.get(NAMESPACE).isTextual()) {
 throw new IllegalArgumentException("No namespace specified!");
} else if (!object.has(NAME) || !object.get(NAME).isTextual()) {
 throw new IllegalArgumentException("No name specified!");
} else {
 fqn = object.get(NAMESPACE).getTextValue() + "." + object.get(NAME).getTextValue();
if (!object.has(VERSION) || !object.get(VERSION).isInt()) {
 object.put(VERSION, 1);
schema.setVersion(object.get(VERSION).asInt());
if (!object.has(DEPENDENCIES)) {
 schema.setDependencySet(dependencies);
} else if (!object.get(DEPENDENCIES).isArray()) {
 throw new IllegalArgumentException("Illegal dependencies format!");
} else {
 for (JsonNode child : object.get(DEPENDENCIES)) {
  if (!child.isObject() || !child.has(FQN) || !child.get(FQN).isTextual()
    || !child.has(VERSION) || !child.get(VERSION).isInt()) {
origin: org.codehaus.jackson/jackson-mapper-asl

public Object(JsonNode n, NodeCursor p)
{
  super(JsonStreamContext.TYPE_OBJECT, p);
  _contents = ((ObjectNode) n).getFields();
  _needEntry = true;
}
origin: soabase/exhibitor

  ArrayNode           dataTab = JsonNodeFactory.instance.arrayNode();
  for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i )
      ObjectNode      data = JsonNodeFactory.instance.objectNode();
      int             docId = cachedSearch.getNthDocId(i);
      SearchItem      item = logSearch.toResult(docId);
      data.put("DT_RowId", "index-query-result-" + docId);
      data.put("0", getTypeName(EntryTypes.getFromId(item.getType())));
      data.put("1", dateFormatter.format(item.getDate()));
      data.put("2", trimPath(item.getPath()));
      dataTab.add(data);
  node = JsonNodeFactory.instance.objectNode();
  node.put("sEcho", sEcho);
  node.put("iTotalRecords", logSearch.getDocQty());
  node.put("iTotalDisplayRecords", cachedSearch.getTotalHits());
  node.put("aaData", dataTab);
return node.toString();
origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public boolean equals(Object o)
{
  if (o == this) return true;
  if (o == null) return false;
  if (o.getClass() != getClass()) {
    return false;
  }
  ObjectNode other = (ObjectNode) o;
  if (other.size() != size()) {
    return false;
  }
  if (_children != null) {
    for (Map.Entry<String, JsonNode> en : _children.entrySet()) {
      String key = en.getKey();
      JsonNode value = en.getValue();
      JsonNode otherValue = other.get(key);
      if (otherValue == null || !otherValue.equals(value)) {
        return false;
      }
    }
  }
  return true;
}
origin: soabase/exhibitor

public String   getNodeData(@QueryParam("key") String key) throws Exception
  ObjectNode node = JsonNodeFactory.instance.objectNode();
  try
      node.put("bytes", bytesToString(bytes));
      node.put("str", new String(bytes, "UTF-8"));
    } else {
      node.put("bytes", "");
      node.put("str", "");
    node.put("stat", reflectToString(stat));
    node.put("bytes", "");
    node.put("str", "");
    node.put("stat", "* not found * ");
    node.put("bytes", "");
    node.put("str", "Exception");
    node.put("stat", e.getMessage());
  return node.toString();
origin: org.codehaus.jackson/jackson-mapper-asl

objectNode.put("type", schemaType);
if (objectProperties != null) {
  try {
    objectNode.put("properties", new ObjectMapper().readValue(objectProperties, JsonNode.class));
  } catch (IOException e) {
    throw new IllegalStateException(e);
    objectNode.put("items", new ObjectMapper().readValue(itemDefinition, JsonNode.class));
  } catch (IOException e) {
    throw new IllegalStateException(e);
origin: kaaproject/kaa

 private List<FileData> recursiveShallowExport(List<FileData> files, CTLSchemaDto parent) throws
     Exception {
  files.add(this.shallowExport(parent));
  ObjectNode object = new ObjectMapper().readValue(parent.getBody(), ObjectNode.class);
  ArrayNode dependencies = (ArrayNode) object.get(DEPENDENCIES);
  if (dependencies != null) {
   for (JsonNode node : dependencies) {
    ObjectNode dependency = (ObjectNode) node;
    String fqn = dependency.get(FQN).getTextValue();
    Integer version = dependency.get(VERSION).getIntValue();
    CTLSchemaDto child = this.findAnyCtlSchemaByFqnAndVerAndTenantIdAndApplicationId(
        fqn, version, parent.getMetaInfo().getTenantId(),
        parent.getMetaInfo().getApplicationId());
    Validate.notNull(child, MessageFormat.format("The dependency [{0}] was not found!", fqn));
    this.recursiveShallowExport(files, child);
   }
  }
  return files;
 }
}
origin: de.mhus.lib/mhu-lib-core

public JsonConfig(String json) throws Exception {
  ObjectMapper mapper = new ObjectMapper();
  JsonNode nodex = mapper.readValue(json, JsonNode.class);
  if (nodex instanceof ObjectNode)
    node = (ObjectNode) nodex;
  else {
    node = ((ArrayNode)nodex).objectNode();
    node.put("default", nodex);
  }
}

origin: gravel-st/gravel

public static Map<String, Object> parseAsJSONValue(String src) {
  ObjectMapper mapper = new ObjectMapper();
  ObjectNode rootNode;
  try {
    rootNode = (ObjectNode) mapper.readValue(src, JsonNode.class);
  } catch (JsonParseException e) {
    throw new RuntimeException(e);
  } catch (JsonMappingException e) {
    throw new RuntimeException(e);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  HashMap<String, Object> map = new HashMap<String, Object>();
  for (Iterator<Entry<String, JsonNode>> iter = rootNode.getFields(); iter
      .hasNext();) {
    Entry<String, JsonNode> field = iter.next();
    JsonNode value = field.getValue();
    Object o = jsonNodeAsSimpleObject(value);
    map.put(field.getKey(), o);
  }
  return map;
}
origin: soabase/exhibitor

ObjectMapper        mapper = new ObjectMapper();
ObjectNode          node = JsonNodeFactory.instance.objectNode();
if ( responseIsJson )
  node.put("response", mapper.readTree(mapper.getJsonFactory().createJsonParser(remoteResponse)));
  node.put("response", remoteResponse);
node.put("errorMessage", errorMessage);
node.put("success", errorMessage.length() == 0);
origin: org.apache.curator/curator-x-discovery-server

@Override
public void writeTo(ServiceNames serviceNames, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException
{
  ObjectMapper        mapper = new ObjectMapper();
  ArrayNode           arrayNode = mapper.createArrayNode();
  for ( String name : serviceNames.getNames() )
  {
    ObjectNode      node = mapper.createObjectNode();
    node.put("name", name);
    arrayNode.add(node);
  }
  mapper.writer().writeValue(entityStream, arrayNode);
}
origin: oVirt/ovirt-engine

@BeforeEach
public void setUpMockRequest() {
  ObjectMapper mapper = new ObjectMapper();
  ObjectNode mockPluginDef = mapper.createObjectNode();
  mockPluginDef.put("foo", "bar"); //$NON-NLS-1$ //$NON-NLS-2$
  mockPluginDefinitionsArray = mapper.createArrayNode();
  mockPluginDefinitionsArray.add(mockPluginDef);
  when(mockApplicationModeObject.toString()).thenReturn(APPLICATION_MODE);
  when(mockRequest.getAttribute(WebAdminHostPageServlet.ATTR_APPLICATION_MODE)).thenReturn(mockApplicationModeObject);
  when(mockRequest.getAttribute(WebAdminHostPageServlet.ATTR_PLUGIN_DEFS)).thenReturn(mockPluginDefinitionsArray);
}
origin: kaaproject/kaa

/**
 * Change encoding of uuids  from <b>latin1 (ISO-8859-1)</b> to <b>base64</b>.
 *
 * @param json the json that should be processed
 * @return the json with changed uuids
 * @throws IOException the io exception
 */
public static JsonNode encodeUuids(JsonNode json) throws IOException {
 if (json.has(UUID_FIELD)) {
  JsonNode jsonNode = json.get(UUID_FIELD);
  if (jsonNode.has(UUID_VALUE)) {
   String value = jsonNode.get(UUID_VALUE).asText();
   String encodedValue = Base64.getEncoder().encodeToString(value.getBytes("ISO-8859-1"));
   ((ObjectNode) jsonNode).put(UUID_VALUE, encodedValue);
  }
 }
 for (JsonNode node : json) {
  if (node.isContainerNode()) {
   encodeUuids(node);
  }
 }
 return json;
}
origin: apache/samza

/**
 * Given a {@link ContainerModel} JSON with an unknown field, deserialization should properly ignore it.
 */
@Test
public void testDeserializeUnknownTaskModelField() throws IOException {
 ObjectNode jobModelJson = buildJobModelJson();
 ObjectNode taskModelJson = (ObjectNode) jobModelJson.get("containers").get("1").get("tasks").get("test");
 taskModelJson.put("unknown_task_model_key", "unknown_task_model_value");
 assertEquals(this.jobModel, deserializeFromObjectNode(jobModelJson));
}
origin: org.apache.eagle/eagle-service-base

private void addTo( ObjectNode resourceNode, String uriPrefix, AbstractResourceMethod srm, String path ){
  if(resourceNode.get( uriPrefix ) == null){
    ObjectNode inner = JsonNodeFactory.instance.objectNode();
    inner.put("path", path);
    inner.put("methods", JsonNodeFactory.instance.arrayNode());
    resourceNode.put( uriPrefix, inner );
  }
  ((ArrayNode) resourceNode.get( uriPrefix ).get("methods")).add( srm.getHttpMethod() );
}
origin: org.apache.stanbol/org.apache.stanbol.enhancer.nlp.json

@Override
public ObjectNode serialize(ObjectMapper mapper, CorefFeature coref) {
  ObjectNode jCoref = mapper.createObjectNode();
  
  jCoref.put(IS_REPRESENTATIVE_TAG, coref.isRepresentative());
  
  Set<Span> mentions = coref.getMentions(); 
  ArrayNode jMentions = mapper.createArrayNode();
  
  for(Span mention : mentions) {
    ObjectNode jMention = mapper.createObjectNode();
    
    jMention.put(MENTION_TYPE_TAG, mention.getType().toString());
    jMention.put(MENTION_START_TAG, mention.getStart());
    jMention.put(MENTION_END_TAG, mention.getEnd());
    
    jMentions.add(jMention);
  }
  
  jCoref.put(MENTIONS_TAG, jMentions);
  
  return jCoref;
}
origin: apache/helix

@GET
@Path("{instanceName}/healthreports")
public Response getHealthReportsOnInstance(@PathParam("clusterId") String clusterId,
  @PathParam("instanceName") String instanceName) throws IOException {
 HelixDataAccessor accessor = getDataAccssor(clusterId);
 ObjectNode root = JsonNodeFactory.instance.objectNode();
 root.put(Properties.id.name(), instanceName);
 ArrayNode healthReportsNode = root.putArray(InstanceProperties.healthreports.name());
 List<String> healthReports =
   accessor.getChildNames(accessor.keyBuilder().healthReports(instanceName));
 if (healthReports != null && healthReports.size() > 0) {
  healthReportsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(healthReports));
 }
 return JSONRepresentation(root);
}
origin: kaaproject/kaa

private static JsonNode injectUuidsFromJsonNodes(JsonNode json, Schema schema) {
 if (json == null) {
  return json;
 }
 switch (schema.getType()) {
  case RECORD:
   schema.getFields().stream()
     .filter(f -> !f.name().equals(UUID_FIELD))
     .forEach(f -> injectUuidsFromJsonNodes(json.get(f.name()), f.schema()));
   boolean addressable = schema.getFields().stream().filter(f -> f.name().equals(
       UUID_FIELD)).findFirst().isPresent();
   if (addressable) {
    ((ObjectNode) json).put(UUID_FIELD, (Integer) null);
   }
   break;
  case UNION:
   schema.getTypes()
     .forEach(s -> injectUuidsFromJsonNodes(json.get(s.getName()), s));
   break;
  case ARRAY:
   json.getElements().forEachRemaining((elem) -> injectUuids(elem, schema.getElementType()));
   break;
  default:
   return json;
 }
 return json;
}
origin: de.mhus.lib/mhu-lib-core

@Override
public List<IConfig> getNodes() {
  LinkedList<IConfig> out = new LinkedList<>();
  for ( Map.Entry<String, JsonNode> entry : MCollection.iterate(node.getFields()) ) {
    JsonNode child = entry.getValue();
    String childName = entry.getKey();
    if (child !=null && child.isArray()) {
      for (int i = 0; i < child.size(); i++)
        out.add( new JsonConfig(childName, this, child.get(i)));
    } else
    if (child !=null && child.isObject())
      out.add( new JsonConfig(childName, this, child));
  }
  return out;
}

origin: eBay/YiDB

@Test
public void testQueryExplanation_typeCast2() {
  String query = "ResourceGroup.<ResourceGroup>children{*}";
  QueryContext qc = newQueryContext(CMSDB_REPO, IBranch.DEFAULT_BRANCH);
  qc.setAllowFullTableScan(true);
  qc.setExplain(true);
  IQueryResult queryResult = queryService.query(query, qc);
  Assert.assertNotNull(queryResult.getExplanations());
  List<IQueryExplanation> explans = queryResult.getExplanations();
  Assert.assertEquals(3, explans.size());
  // first two is search explanation, the last one is the join explanation
  ObjectNode objectNode = (ObjectNode) explans.get(0).getJsonExplanation();
  String queryType0 = objectNode.get("criteria").get("$and").get(0).get("_t").getTextValue();
  Assert.assertTrue(queryType0.equals("ResourceGroup"));
  Assert.assertTrue(objectNode.has("usedTime"));
  Assert.assertTrue(objectNode.has("limit"));
  Assert.assertTrue(objectNode.has("sort"));
  objectNode = (ObjectNode) explans.get(1).getJsonExplanation();
  String queryType1 = objectNode.get("criteria").get("$and").get(0).get("_t").getTextValue();
  Assert.assertTrue(queryType1.equals("ResourceGroup"));
}
org.codehaus.jackson.nodeObjectNode

Javadoc

Node that maps to JSON Object structures in JSON content.

Most used methods

  • put
    Method for setting value of a field to specified binary value
  • get
  • getFields
    Method to use for accessing all fields (with both names and values) of this JSON Object.
  • toString
  • putArray
    Method that will construct an ArrayNode and add it as a field of this ObjectNode, replacing old valu
  • has
  • remove
    Method for removing specified field properties out of this ObjectNode.
  • objectNode
  • size
  • <init>
  • arrayNode
  • putObject
    Method that will construct an ObjectNode and add it as a field of this ObjectNode, replacing old val
  • arrayNode,
  • putObject,
  • nullNode,
  • path,
  • putNull,
  • POJONode,
  • _put,
  • binaryNode,
  • booleanNode,
  • equals

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
  • addToBackStack (FragmentTransaction)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • JTextField (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now