Refine search
public String getClassName(String propertyName, JsonNode node) { if (node != null) { if (node.has("javaName")) { propertyName = node.get("javaName").textValue(); } else if (generationConfig.isUseTitleAsClassname() && node.has("title")) { String title = node.get("title").textValue(); propertyName = WordUtils.capitalize(title).replaceAll(" ", ""); } } return propertyName; }
public ObjectSchemaSelector(final JsonNode digest) { hasAdditional = digest.get("hasAdditional").booleanValue(); List<String> list; list = Lists.newArrayList(); for (final JsonNode node: digest.get("properties")) list.add(node.textValue()); properties = ImmutableList.copyOf(list); list = Lists.newArrayList(); for (final JsonNode node: digest.get("patternProperties")) list.add(node.textValue()); patternProperties = ImmutableList.copyOf(list); }
public AdditionalPropertiesValidator(final JsonNode digest) { super("additionalProperties"); additionalOK = digest.get(keyword).booleanValue(); ImmutableSet.Builder<String> builder; builder = ImmutableSet.builder(); for (final JsonNode node: digest.get("properties")) builder.add(node.textValue()); properties = builder.build(); builder = ImmutableSet.builder(); for (final JsonNode node: digest.get("patternProperties")) builder.add(node.textValue()); patternProperties = builder.build(); }
@Override public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isTextual()) { return node.textValue(); } else if (node.isObject()) { JsonNode allNode = node.get("__all__"); if (allNode != null && allNode.isArray()) { StringBuilder buf = new StringBuilder(); for (JsonNode msgNode : allNode) { buf.append(msgNode.textValue()); buf.append(","); } return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString(); } return node.toString(); } return null; } }
static Set<String> parseAliases(JsonNode node) { JsonNode aliasesNode = node.get("aliases"); if (aliasesNode == null) return null; if (!aliasesNode.isArray()) throw new SchemaParseException("aliases not an array: "+node); Set<String> aliases = new LinkedHashSet<>(); for (JsonNode aliasNode : aliasesNode) { if (!aliasNode.isTextual()) throw new SchemaParseException("alias not a string: "+aliasNode); aliases.add(aliasNode.textValue()); } return aliases; }
private static SchemeType loadType(JsonNode node) throws IOException { if (node.size() > 0) { String complexNode = node.get("type").textValue(); if (complexNode.equals("list")) { return new SchemeListType(loadType(node.get("childType"))); } else if (complexNode.equals("struct")) { return new SchemeStructType(node.get("childType").textValue()); } else if (complexNode.equals("opt")) { return new SchemeOptionalType(loadType(node.get("childType"))); } else if (complexNode.equals("enum")) { return new SchemeEnumType(node.get("childType").textValue()); } else if (complexNode.equals("alias")) { return new SchemeAliasType(node.get("childType").textValue()); } else if (complexNode.equals("trait")) { return new SchemeTraitType(node.get("childType").textValue()); } else { throw new IOException(); } } else { return new SchemePrimitiveType(node.textValue()); } }
/** * Returns a {@link JsonNode} which is converted from a {@link Response} object. The {@link JsonNode} * will be converted as JSON string by the {@link JacksonResponseConverterFunction}. */ @Post("/node/node") public JsonNode json1(@RequestObject JsonNode input) { final JsonNode name = input.get("name"); return mapper.valueToTree(new Response(Response.SUCCESS, name.textValue())); }
@Override public KucoinActiveOrder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode root = p.readValueAsTree(); if (root.isArray()) { Date timestamp = new Date(root.get(0).asLong()); KucoinOrderType orderType = KucoinOrderType.valueOf(root.get(1).asText()); BigDecimal price = root.get(2).decimalValue(); BigDecimal amount = root.get(3).decimalValue(); BigDecimal dealAmount = root.get(4).decimalValue(); // amount already filled String orderOid = root.get(5).textValue(); return new KucoinActiveOrder(timestamp, orderType, price, amount, dealAmount, orderOid); } else { throw new RuntimeException("KucoinDealOrder should have an array as root node!"); } } }
/** * Returns a {@link Response} object. The {@link ProducesJson} annotation makes an object be converted * as JSON string by the {@link JacksonResponseConverterFunction}. */ @Post("/node/obj") @ProducesJson public Response json2(@RequestObject JsonNode input) { final JsonNode name = input.get("name"); return new Response(Response.SUCCESS, name.textValue()); }