changeset 20:9b10f33bcf90

helper class for playing around with JSON
author dirk
date Sat, 17 Sep 2011 09:22:30 +0200
parents 97a113e27ed8
children 4734cbeb8683
files conflict-editor/src/test/java/de/codedo/conflicteditor/JsonPlayground.java
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/conflict-editor/src/test/java/de/codedo/conflicteditor/JsonPlayground.java	Sat Sep 17 09:22:30 2011 +0200
@@ -0,0 +1,26 @@
+
+package de.codedo.conflicteditor;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+
+public class JsonPlayground
+{
+    public static void main(String[] args) throws Exception
+    {
+        printNodeToken("{ \"key\" : \"string\" }"); // VALUE_STRING
+        printNodeToken("{ \"key\" : 1 }"); // VALUE_NUMBER_INT
+        printNodeToken("{ \"key\" : 1.1 }"); // VALUE_NUMBER_FLOAT
+        printNodeToken("{ \"key\" : true }"); // VALUE_TRUE
+        printNodeToken("{ \"key\" : false }"); // VALUE_FALSE
+        printNodeToken("{ \"key\" : [] }"); // START_ARRAY
+        printNodeToken("{ \"key\" : {} }"); // START_OBJECT
+
+    }
+
+    private static void printNodeToken(String input) throws Exception
+    {
+        JsonNode node = new ObjectMapper().readTree(input);
+        System.out.println(node.get("key").asToken());
+    }
+}