/** * Factory method that constructs and returns an empty {@link ArrayNode} * Construction is done using registered {@link JsonNodeFactory}. */ public final ArrayNode arrayNode() { return _nodeFactory.arrayNode(); }
@Override public JsonNode createArrayNode() { return _config.getNodeFactory().arrayNode(); }
/** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) * * @since 1.2 */ @Override public ArrayNode createArrayNode() { return _deserializationConfig.getNodeFactory().arrayNode(); }
@Path("list") @GET @Produces(MediaType.APPLICATION_JSON) public String getClusterAsJson() throws Exception { InstanceConfig config = context.getExhibitor().getConfigManager().getConfig(); ObjectNode node = JsonNodeFactory.instance.objectNode(); ArrayNode serversNode = JsonNodeFactory.instance.arrayNode(); ServerList serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC)); for ( ServerSpec spec : serverList.getSpecs() ) { serversNode.add(spec.getHostname()); } node.put("servers", serversNode); node.put("port", config.getInt(IntConfigs.CLIENT_PORT)); return JsonUtil.writeValueAsString(node); }
public String getNode(@QueryParam("key") String key) throws Exception ArrayNode children = JsonNodeFactory.instance.arrayNode(); try
/** * Creates the class type field. * * @return the field */ private Field createClassTypeField() { List<String> classTypeSymbols = Arrays.asList(OBJECT, EVENT); Schema classTypeEnum = Schema.createEnum(CLASS_TYPE_TYPE_NAME, null, BASE_SCHEMA_FORM_NAMESPACE, classTypeSymbols); Field classTypeField = new Field(CLASS_TYPE, classTypeEnum, null, null); classTypeField.addProp(DISPLAY_NAME, "Class type"); JsonNodeFactory jsonFactory = JsonNodeFactory.instance; ArrayNode displayNamesNode = jsonFactory.arrayNode(); displayNamesNode.add(TextNode.valueOf("Object")); displayNamesNode.add(TextNode.valueOf("Event")); classTypeField.addProp(DISPLAY_NAMES, displayNamesNode); classTypeField.addProp(DISPLAY_PROMPT, "Select class type"); classTypeField.addProp(BY_DEFAULT, OBJECT); return classTypeField; }
/** * Creates the override strategy field. * * @return the field */ private Field createOverrideStrategyField() { List<String> overrideStrategySymbols = Arrays.asList(OverrideStrategy.APPEND.name(), OverrideStrategy.REPLACE.name()); Schema overrideStrategyEnum = Schema.createEnum(OVERRIDE_STRATEGY_TYPE_NAME, null, BASE_SCHEMA_FORM_NAMESPACE, overrideStrategySymbols); Field overrideStrategyField = new Field(OVERRIDE_STRATEGY, Schema.createUnion(Arrays.asList( overrideStrategyEnum, Schema.create(Type.NULL))), null, null); overrideStrategyField.addProp(DISPLAY_NAME, "Override strategy"); JsonNodeFactory jsonFactory = JsonNodeFactory.instance; ArrayNode displayNamesNode = jsonFactory.arrayNode(); displayNamesNode.add(TextNode.valueOf("Append")); displayNamesNode.add(TextNode.valueOf("Replace")); overrideStrategyField.addProp(DISPLAY_NAMES, displayNamesNode); overrideStrategyField.addProp(DISPLAY_PROMPT, "Select array override strategy"); return overrideStrategyField; }
/** * Factory method that constructs and returns an empty {@link ArrayNode} * Construction is done using registered {@link JsonNodeFactory}. */ public final ArrayNode arrayNode() { return _nodeFactory.arrayNode(); }
ArrayNode dataTab = JsonNodeFactory.instance.arrayNode(); for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i )
@Path("backup-config") @GET @Produces(MediaType.APPLICATION_JSON) public String getBackupConfig() throws Exception { ArrayNode node = JsonNodeFactory.instance.arrayNode(); if ( context.getExhibitor().getBackupManager().isActive() ) { EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser(); List<BackupConfigSpec> configs = context.getExhibitor().getBackupManager().getConfigSpecs(); for ( BackupConfigSpec c : configs ) { ObjectNode n = JsonNodeFactory.instance.objectNode(); String value = parser.getValue(c.getKey()); n.put("key", c.getKey()); n.put("name", c.getDisplayName()); n.put("help", c.getHelpText()); n.put("value", (value != null) ? value : ""); n.put("type", c.getType().name().toLowerCase().substring(0, 1)); node.add(n); } } return JsonUtil.writeValueAsString(node); }
protected final ArrayNode deserializeArray(JsonParser jp, DeserializationContext ctxt, final JsonNodeFactory nodeFactory) throws IOException, JsonProcessingException { ArrayNode node = nodeFactory.arrayNode(); while (true) { switch (jp.nextToken()) { case START_OBJECT: node.add(deserializeObject(jp, ctxt, nodeFactory)); break; case START_ARRAY: node.add(deserializeArray(jp, ctxt, nodeFactory)); break; case END_ARRAY: return node; case VALUE_STRING: node.add(nodeFactory.textNode(jp.getText())); break; default: node.add(deserializeAny(jp, ctxt, nodeFactory)); break; } } }
return NullNode.getInstance(); case ARRAY: ArrayNode array = JsonNodeFactory.instance.arrayNode(); for (long l = in.readArrayStart(); l > 0; l = in.arrayNext()) for (long i = 0; i < l; i++)
/** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) * * @since 1.2 */ @Override public ArrayNode createArrayNode() { return _deserializationConfig.getNodeFactory().arrayNode(); }
@Override public JsonNode createArrayNode() { return _config.getNodeFactory().arrayNode(); }
public String getSerializedJSON(final List<MetricName> metricNames) { ArrayNode tokenInfoArrayNode = JsonNodeFactory.instance.arrayNode(); for (MetricName metricName : metricNames) { ObjectNode metricNameInfoNode = JsonNodeFactory.instance.objectNode(); metricNameInfoNode.put(metricName.getName(), JsonNodeFactory.instance.booleanNode(metricName.isCompleteName())); tokenInfoArrayNode.add(metricNameInfoNode); } return tokenInfoArrayNode.toString(); } }
public static String getSerializedJSON(List<SearchResult> searchResults) { ArrayNode resultArray = JsonNodeFactory.instance.arrayNode(); for (SearchResult result : searchResults) { ObjectNode resultNode = JsonNodeFactory.instance.objectNode(); resultNode.put("metric", result.getMetricName()); String unit = result.getUnit(); if (unit != null) { //Preaggreated metrics do not have units. Do not want to return null units in query results. resultNode.put("unit", unit); } resultArray.add(resultNode); } return resultArray.toString(); } }
/** * Factory method that constructs and returns an empty {@link ArrayNode} * Construction is done using registered {@link JsonNodeFactory}. */ public final ArrayNode arrayNode() { return _nodeFactory.arrayNode(); }
protected final ArrayNode deserializeArray(JsonParser jp, DeserializationContext ctxt, final JsonNodeFactory nodeFactory) throws IOException, JsonProcessingException { ArrayNode node = nodeFactory.arrayNode(); while (true) { switch (jp.nextToken()) { case START_OBJECT: node.add(deserializeObject(jp, ctxt, nodeFactory)); break; case START_ARRAY: node.add(deserializeArray(jp, ctxt, nodeFactory)); break; case END_ARRAY: return node; case VALUE_STRING: node.add(nodeFactory.textNode(jp.getText())); break; default: node.add(deserializeAny(jp, ctxt, nodeFactory)); break; } } }
private ArrayNode compactionStrategyMap(Function<AbstractCompactionStrategy, JsonNode> select) { ArrayNode node = json.arrayNode(); forEach(acs -> node.add(select.apply(acs))); return node; }
public static ArrayNode toJsonArray(final short... values){ final ArrayNode result = ThreadLocalJsonFactory.getFactory().arrayNode(); for(final short value: values) result.add(value); return result; }