@@ -0,0 +1,2611 @@
+/**%0A * Copyright (c) 2011, Jilles van Gurp%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0Apackage org.jsonj;%0A%0Aimport static org.jsonj.tools.JsonBuilder.array;%0Aimport static org.jsonj.tools.JsonBuilder.nullValue;%0Aimport static org.jsonj.tools.JsonBuilder.object;%0Aimport static org.jsonj.tools.JsonBuilder.primitive;%0Aimport static org.jsonj.tools.JsonSerializer.serialize;%0Aimport static org.jsonj.tools.JsonSerializer.write;%0A%0Aimport java.io.IOException;%0A%0Aimport org.jsonj.tools.JsonParser;%0Aimport org.testng.annotations.Test;%0A%0A/**%0A * Not really a test but a nice place to show off some how to use this.%0A */%0A@Test%0Apublic class ShowOffTheFramework %7B%0A%0A%09/** this could be a singleton or a spring injected object, threadsafe of course. */%0A%09private final JsonParser jsonParser = new JsonParser();;%0A%0A%09public void whatCanThisBabyDo() throws IOException %7B%0A%09%09JsonObject object = object()%0A%09%09%09.put(%22its%22, %22just a hash map%22)%0A%09%09%09.put(%22and%22, array(primitive(%22adding%22), primitive(%22stuff%22), object().put(%22is%22, %22easy%22).get(), array(%22another array%22)))%0A%09%09%09.put(%22numbers%22, 42)%0A%09%09%09.put(%22including_this_one%22, 42.0)%0A%09%09%09.put(%22booleanstoo%22, true)%0A%09%09%09.put(%22nulls_if_you_insist%22, nullValue())%0A%09%09%09.put(%22arrays_are_easy%22, array(%221%22, %222%22, %22etc%22, %22varargs are nice%22)).get();%0A%0A%09%09// serialize like this%0A%09%09String serialized = serialize(object);%0A%0A%09%09System.out.println(serialized);%0A%0A%09%09// parse it%0A%09%09JsonElement json = jsonParser.parse(serialized);%0A%0A%09%09// and write it straight to some stream%0A%09%09write(System.out, json, false);%0A%0A%09%09// or pretty print it like this%0A%09%09System.out.println(%22%5Cn%22 + serialize(json, true));%0A%0A%09%7D%0A%7D%0A

Add test to show off the features of this framework.