我尝试在phpdbg控制台中调用命令:
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class JsonSample {
public static void main(String[] args) {
JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
ObjectNode heirachy = nodeFactory.objectNode();
ArrayNode parents = nodeFactory.arrayNode();
//Parents
ObjectNode parent1 = nodeFactory.objectNode();
parent1.put("name", "Parent1");
parent1.put("isParent", "true");
ObjectNode parent2 = nodeFactory.objectNode();
parent2.put("name", "Parent2");
parent2.put("isParent", "true");
ObjectNode parent3 = nodeFactory.objectNode();
parent3.put("name", "Parent3");
parent3.put("isParent", "true");
ArrayNode parent3Arr = nodeFactory.arrayNode();
ObjectNode innerParent3 = nodeFactory.objectNode();
innerParent3.put("name", "Inner-Parent3");
innerParent3.put("isParent", "true");
ArrayNode innerParent3Arr = nodeFactory.arrayNode();
ObjectNode innermostParent3 = nodeFactory.objectNode();
innermostParent3.put("name", "Inner-most-Parent3");
innermostParent3.put("isParent", "true");
innerParent3Arr.add(innermostParent3);
innerParent3.put("parents", innerParent3Arr);
parent3Arr.add(innerParent3);
parent3.put("parents", parent3Arr);
parents.add(parent1);
parents.add(parent2);
parents.add(parent3);
//Children
ArrayNode children = nodeFactory.arrayNode();
ObjectNode child1 = nodeFactory.objectNode();
child1.put("name", "Child1");
child1.put("isParent", "false");
ObjectNode child2 = nodeFactory.objectNode();
child2.put("name", "Child2");
child2.put("isParent", "false");
ObjectNode child3 = nodeFactory.objectNode();
child3.put("name", "Child3");
child3.put("isParent", "false");
ArrayNode child3Arr = nodeFactory.arrayNode();
ObjectNode innerChild3 = nodeFactory.objectNode();
innerChild3.put("name", "Inner-Child3");
innerChild3.put("isParent", "false");
ArrayNode innerChild3Arr = nodeFactory.arrayNode();
ObjectNode innermostChild3 = nodeFactory.objectNode();
innermostChild3.put("name", "Inner-most-Child3");
innermostChild3.put("isParent", "false");
innerChild3Arr.add(innermostChild3);
innerChild3.put("children", innerChild3Arr);
child3Arr.add(innerChild3);
child3.put("children", child3Arr);
children.add(child1);
children.add(child2);
children.add(child3);
heirachy.put("name", "Hierarchy");
heirachy.put("parents", parents);
heirachy.put("children", children);
System.out.println(heirachy);
}
}
结果是:
argv --m=find --filters={"id":4}
问题在于冒号“:”。 当我从论证中删除它时,一切都很好。 但我需要它,在没有翻译的情况下传递参数中的json数据。
[Parse Error: syntax error, unexpected identifier (command or function name), expecting # (pound sign) or digits (numbers)]
--> STR_PARAM(argv=4)
--> STR_PARAM(--m=find=8)
或
argv --m=find --filters={"id"\:4}
或甚至
argv --m=find '--filters={"id":4}'
PS。 argv '--m=find --filters={"id":4}'
是.phpdbginit of Krakjoe中用户注册的命令。