本文整理了Java中org.codehaus.jackson.node.ObjectNode.getFields()
方法的一些代码示例,展示了ObjectNode.getFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectNode.getFields()
方法的具体详情如下:
包路径:org.codehaus.jackson.node.ObjectNode
类名称:ObjectNode
方法名:getFields
[英]Method to use for accessing all fields (with both names and values) of this JSON Object.
[中]方法用于访问此JSON对象的所有字段(包括名称和值)。
代码示例来源: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: camunda/camunda-bpm-platform
public Object(JsonNode n, NodeCursor p)
{
super(JsonStreamContext.TYPE_OBJECT, p);
_contents = ((ObjectNode) n).getFields();
_needEntry = true;
}
代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson
public Object(JsonNode n, NodeCursor p)
{
super(JsonStreamContext.TYPE_OBJECT, p);
_contents = ((ObjectNode) n).getFields();
_needEntry = true;
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl
public Object(JsonNode n, NodeCursor p)
{
super(JsonStreamContext.TYPE_OBJECT, p);
_contents = ((ObjectNode) n).getFields();
_needEntry = true;
}
代码示例来源:origin: ovea-deprecated/jetty-session-redis
public Object(JsonNode n, NodeCursor p)
{
super(JsonStreamContext.TYPE_OBJECT, p);
_contents = ((ObjectNode) n).getFields();
_needEntry = true;
}
代码示例来源:origin: stackoverflow.com
public class AnnotationDeserializer extends StdDeserializer<Annotation> {
AnnotationDeserializer() {
super(Annotation.class);
}
@Override
public Annotation deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(jp);
Class<? extends Annotation> realClass = null;
Iterator<Entry<String, JsonNode>> elementsIterator = root.getFields();
while (elementsIterator.hasNext()) {
Entry<String, JsonNode> element = elementsIterator.next();
if ("type".equals(element.getKey())) {
realClass = AnnotationObjectFactory.getInstance()
.getAnnotationClass(element.getKey());
break;
}
}
if (realClass == null)
return null;
return mapper.readValue(root, realClass);
}
}
代码示例来源:origin: stackoverflow.com
Iterator<Entry<String, JsonNode>> iterator = root.getFields();
boolean found = false;
while (!found &&iterator.hasNext()) {
代码示例来源:origin: stackoverflow.com
public class MyDeserializer extends JsonDeserializer< Message >
{
@Override
public Message deserialize( JsonParser jp, DeserializationContext arg1 ) throws IOException,
JsonProcessingException
{
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(jp);
Class<? extends Message> subClass = null;
Iterator<Entry<String, JsonNode>> elementsIterator = root.getFields();
while (elementsIterator.hasNext())
{
Entry<String, JsonNode> element = elementsIterator.next();
String name = element.getKey();
if ("foo_id".equals(name))
{
if(element.getValue().isInt())
subClass = FooInteger.Class;
break;
}
}
if (subClass == null) return null;
return mapper.readValue(root, subClass);
}
}
代码示例来源: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: com.github.foodev/jsondiff
@Override
public Collection<? extends Entry<String, JzonElement>> entrySet() {
HashSet<Entry<String, JzonElement>> jset = new HashSet<Entry<String, JzonElement>>();
for (Iterator<Entry<String, JsonNode>> i = wrapped.getFields(); i.hasNext();) {
final Entry<String, JsonNode> e = i.next();
final JzonElement el = JacksonWrapper.wrap(e.getValue());
jset.add(new Entry<String, JzonElement>() {
@Override
public String getKey() {
return e.getKey();
}
@Override
public JzonElement getValue() {
return el;
}
@Override
public JzonElement setValue(JzonElement value) {
throw new UnsupportedOperationException();
}
});
}
return jset;
}
代码示例来源:origin: sirensolutions/siren
/**
* The generateFacetsForLeaves() method for processing json objects, delegates for each field and constructs path.
*/
private void generateFacetsForLeaves(ObjectNode object, String fieldName, ExtendedJsonField sirenField, String path,
List<SirenFacetEntry> facets) {
Iterator<Entry<String, JsonNode>> iterator = object.getFields();
while (iterator.hasNext()) {
Entry<String, JsonNode> entry = iterator.next();
String field = entry.getKey();
JsonNode value = entry.getValue();
if (field.equals("_datatype_") || field.equals("_value_")) {
generateFacetsForCustomDatatypeLeaf(object, fieldName, sirenField, path, facets);
return;
}
generateFacetsForLeaves(value, fieldName, sirenField, path.isEmpty() ? field : path + "." + field, facets);
}
}
代码示例来源:origin: algesten/jsondiff
@Override
public Collection<? extends Entry<String, JzonElement>> entrySet() {
HashSet<Entry<String, JzonElement>> jset = new HashSet<Entry<String, JzonElement>>();
for (Iterator<Entry<String, JsonNode>> i = wrapped.getFields(); i.hasNext();) {
final Entry<String, JsonNode> e = i.next();
final JzonElement el = JacksonWrapper.wrap(e.getValue());
jset.add(new Entry<String, JzonElement>() {
@Override
public String getKey() {
return e.getKey();
}
@Override
public JzonElement getValue() {
return el;
}
@Override
public JzonElement setValue(JzonElement value) {
throw new UnsupportedOperationException();
}
});
}
return jset;
}
代码示例来源:origin: com.googlecode.etl-unit/json-validator
private void validatePatternProperties(ObjectNode node, JsonSchemaObjectNode schema, String path) throws JsonSchemaValidationException
{
// iterate through all patterns, and apply to every property for validation
for (Map.Entry<Pattern, JsonSchemaObjectNode> patternSchema : schema.getPatternPropertySchemas().entrySet())
{
Pattern keyPattern = patternSchema.getKey();
JsonSchemaObjectNode keySchema = patternSchema.getValue();
Iterator<Map.Entry<String, JsonNode>> fields = node.getFields();
while (fields.hasNext())
{
Map.Entry<String, JsonNode> field = fields.next();
// check for a pattern match
if (keyPattern.matcher(field.getKey()).matches())
{
// this property matches the pattern, apply the schema
validate(field.getValue(), keySchema, path);
}
}
}
}
}
代码示例来源:origin: NGDATA/lilyproject
public static Configuration getHBaseConfiguration(ZooKeeperItf zk) {
try {
Configuration configuration = HBaseConfiguration.create();
// Make this configuration object 'owned' by us: this way we can close the associated
// connection completely without worrying we close someone else's connection (e.g.
// when running two LilyClient's in one JVM, or when running LilyClient from within
// the lily-server JVM, which is the case when we launch a batch build job)
configuration.set(HConstants.HBASE_CLIENT_INSTANCE_ID, String.valueOf("lilyclient-" + hbaseConfCounter.incrementAndGet()));
byte[] data = zk.getData(hbaseConfigPath, false, new Stat());
ObjectNode propertiesNode = (ObjectNode) JsonFormat.deserializeSoft(data, "HBase configuration");
Iterator<Map.Entry<String, JsonNode>> it = propertiesNode.getFields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
configuration.set(entry.getKey(), entry.getValue().getTextValue());
}
return configuration;
} catch (Exception e) {
throw new RuntimeException("Failed to get HBase configuration from ZooKeeper", e);
}
}
代码示例来源: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: NGDATA/lilyproject
public static Namespaces fromJson(ObjectNode nsNode) throws JsonFormatException {
Namespaces namespaces = new NamespacesImpl();
Iterator<Map.Entry<String, JsonNode>> fieldsIt = nsNode.getFields();
while (fieldsIt.hasNext()) {
Map.Entry<String, JsonNode> entry = fieldsIt.next();
String namespace = entry.getKey();
String prefix;
if (!entry.getValue().isTextual()) {
throw new JsonFormatException("Namespace property should map to a string prefix. Namespace: " +
namespace);
} else {
prefix = entry.getValue().getTextValue();
}
// addMapping will validate that the same prefix is not already bound to another namespace.
namespaces.addMapping(prefix, namespace);
}
return namespaces;
}
代码示例来源:origin: NGDATA/lilyproject
@Override
public RecordVariantFilter fromJson(JsonNode node, Namespaces namespaces, LRepository repository,
RecordFilterJsonConverter<RecordFilter> converter)
throws JsonFormatException, RepositoryException, InterruptedException {
String recordId = JsonUtil.getString(node, "recordId", null);
if (recordId == null) {
throw new IllegalStateException("expected non null recordId in json input");
}
final ObjectNode variantPropertiesNode = JsonUtil.getObject(node, "variantProperties", null);
if (variantPropertiesNode == null) {
throw new IllegalStateException("expected non null variantProperties in json input");
}
final HashMap<String, String> variantProperties = new HashMap<String, String>();
final Iterator<Map.Entry<String, JsonNode>> fields = variantPropertiesNode.getFields();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> next = fields.next();
variantProperties.put(next.getKey(), next.getValue().getTextValue());
}
return new RecordVariantFilter(repository.getIdGenerator().fromString(recordId), variantProperties);
}
}
代码示例来源:origin: com.googlecode.etl-unit/etlunit-core
Iterator<Map.Entry<String, JsonNode>> fields = on.getFields();
代码示例来源:origin: NGDATA/lilyproject
public IndexDefinition(String name, ObjectNode jsonObject) {
this.name = name;
if (jsonObject.get("identifierOrder") != null) {
setIdentifierOrder(Order.valueOf(jsonObject.get("identifierOrder").getTextValue()));
} else {
setIdentifierOrder(Order.ASCENDING);
}
try {
ObjectNode fields = (ObjectNode) jsonObject.get("fields");
Iterator<Map.Entry<String, JsonNode>> fieldsIt = fields.getFields();
while (fieldsIt.hasNext()) {
Map.Entry<String, JsonNode> entry = fieldsIt.next();
String className = entry.getValue().get("class").getTextValue();
Class<IndexFieldDefinition> clazz =
(Class<IndexFieldDefinition>) getClass().getClassLoader().loadClass(className);
Constructor<IndexFieldDefinition> constructor = clazz.getConstructor(String.class, ObjectNode.class);
IndexFieldDefinition field = constructor.newInstance(entry.getKey(), entry.getValue());
add(field);
}
} catch (Exception e) {
throw new RuntimeException("Error instantiating IndexDefinition.", e);
}
}
代码示例来源:origin: CryptoWorldChain/ewallet
public static FieldsMapperBean genQueryMapper(String json) {
FieldsMapperBean fmb = new FieldsMapperBean();
ObjectNode node = JsonUtil.toObjectNode(json);
Iterator<Map.Entry<String, JsonNode>> iter = node.getFields();
while (iter.hasNext()) {
Entry<String, JsonNode> entry = iter.next();
String key = entry.getKey();
JsonNode value = entry.getValue();
SearchField sf = new SearchField();
sf.setFieldName(key);
sf.setShow(value.asInt());
fmb.getFields().add(sf);
}
return fmb;
}
}
内容来源于网络,如有侵权,请联系作者删除!