# HG changeset patch # User dirk # Date 1316244150 -7200 # Node ID 9b10f33bcf90bde3ae14efc8d05b4fc66ac3750b # Parent 97a113e27ed886e3510db7b16aa545a34930c447 helper class for playing around with JSON diff -r 97a113e27ed8 -r 9b10f33bcf90 conflict-editor/src/test/java/de/codedo/conflicteditor/JsonPlayground.java --- /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()); + } +}