All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.infinicast.JObject Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package io.infinicast;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class JObject extends JToken {
    public JObject() {
        super();
    }

    public JObject(JObject rhs) {
        this(rhs.node);
    }

    JObject(JsonNode node) {
        super(node);
    }

    public static JObject Parse(String rhs) {
        ObjectNode node = JsonHelpers.parse(rhs);
        return new JObject(node);
    }

    public boolean containsKey(String key) {
        return node.get(key) != null;
    }

    public Collection getKeys() {

        Iterator stringIterator = node.fieldNames();
        Set col = new HashSet<>();
        while (stringIterator.hasNext()) {
            col.add(stringIterator.next());
        }
        return col;
    }


}







© 2015 - 2024 Weber Informatics LLC | Privacy Policy