com.tinkerpop.rexster.protocol.serializer.json.templates.JsonConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexster-protocol Show documentation
Show all versions of rexster-protocol Show documentation
RexPro is a binary protocol for Rexster graph server.
package com.tinkerpop.rexster.protocol.serializer.json.templates;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ArrayNode;
import org.codehaus.jackson.node.BooleanNode;
import org.codehaus.jackson.node.DoubleNode;
import org.codehaus.jackson.node.IntNode;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.LongNode;
import org.codehaus.jackson.node.NullNode;
import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.node.TextNode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* @author Blake Eggleston (bdeggleston.github.com)
*/
public class JsonConverter {
/**
* Recursively converts objects to json nodes
* @param obj
* @return
*/
public static JsonNode toJsonNode(Object obj) {
if (obj == null) {
return NullNode.getInstance();
} else if (obj instanceof Map) {
ObjectNode map = new ObjectNode(JsonNodeFactory.instance);
for (Map.Entry entry: ((Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy