[jjson] r79 committed - added rest of the google site

1 view
Skip to first unread message

jj...@googlecode.com

unread,
Oct 15, 2011, 2:24:38 AM10/15/11
to jjso...@googlegroups.com
Revision: 79
Author: grobmeier
Date: Fri Oct 14 23:20:38 2011
Log: added rest of the google site
http://code.google.com/p/jjson/source/detail?r=79

Added:
/trunk/jjson/src/site/xdoc/basics.xml
/trunk/jjson/src/site/xdoc/downloads.xml
/trunk/jjson/src/site/xdoc/install.xml
Modified:
/trunk/jjson
/trunk/jjson/src/site/site.xml
/trunk/jjson/src/site/xdoc/index.xml

=======================================
--- /dev/null
+++ /trunk/jjson/src/site/xdoc/basics.xml Fri Oct 14 23:20:38 2011
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>JJSON - A JSON Library for Java without dependencies</title>
+ <author email="grob...@gmail.com">Christian Grobmeier</author>
+ </properties>
+ <!-- Optional HEAD element, which is copied as is into the XHTML <head>
element -->
+ <head>
+ <style type="text/css">
+ h2 {
+ font-size: 50px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- The body of the document contains a number of sections -->
+ <section name="Decoding a json string into a POJO">
+ <p>
+ To map a json string into a POJO, use this:
+ <source>
+
+JSONAnnotationDecoder decoder = new JSONAnnotationDecoder();
+AnnotatedSetTestClass result =
+
decoder.decode(AnnotatedSetTestClass.class, "{\"test1\" : "OK"}");
+result.getTest1() will return "OK" then.
+ </source>
+ </p>
+ </section>
+
+ <section name="Encoding a POJO to JSON">
+ <source>
+
+AnnotatedTestClass c = new AnnotatedTestClass();
+JSONAnnotationEncoder encoder = new JSONAnnotationEncoder();
+String json = encoder.encode(c);
+ </source>
+
+ The AnnotatedTestClass must have @JSON at the class top level and on
any field or method which should
+ be used for the JSON encoding. A field should be public or have
appropriate getters.
+ </section>
+
+ <section name="Object API - Object to JSON">
+ <source>
+
+JSONObject o = new JSONObject();
+o.put("mykey", new JSONString("myvalue"));
+object.toJSON()
+ </source>
+
+ This will result in: {"mykey":"myvalue"}
+ </section>
+
+ <section name="Object API - JSON to Object">
+ You can create JSONObjects from a JSON String too. As all classes
from the API implement JSONValue,
+ you will be mostly operating with that interface.
+
+ <source>
+JSONDecoder decoder = new
JSONDecoder("{\"key\":\"value\",\"key2\":{\"key3\":\"value2\"}}");
+JSONValue result = decoder.decode();
+TestCase.assertEquals("{\"key2\":{\"key3\":\"value2\"},\"key\":\"value\"}",
result.toJSON());
+ </source>
+ </section>
+
+ </body>
+</document>
=======================================
--- /dev/null
+++ /trunk/jjson/src/site/xdoc/downloads.xml Fri Oct 14 23:20:38 2011
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>JJSON - A JSON Library for Java without dependencies</title>
+ <author email="grob...@gmail.com">Christian Grobmeier</author>
+ </properties>
+ <!-- Optional HEAD element, which is copied as is into the XHTML <head>
element -->
+ <head>
+ <style type="text/css">
+ h2 {
+ font-size: 50px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- The body of the document contains a number of sections -->
+ <section name="Downloads">
+ <p>
+ You can get JJSON and its Struts Plugin here:<br/>
+ <a
href="http://code.google.com/p/jjson/downloads/list">http://code.google.com/p/jjson/downloads/list</a>
+ </p>
+ </section>
+
+ </body>
+</document>
=======================================
--- /dev/null
+++ /trunk/jjson/src/site/xdoc/install.xml Fri Oct 14 23:20:38 2011
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>JJSON - A JSON Library for Java without dependencies</title>
+ <author email="grob...@gmail.com">Christian Grobmeier</author>
+ </properties>
+ <!-- Optional HEAD element, which is copied as is into the XHTML <head>
element -->
+ <head>
+ <style type="text/css">
+ h2 {
+ font-size: 50px;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- The body of the document contains a number of sections -->
+ <section name="Install">
+ <p>
+ Just drop the jar-File(s) into your projects classpath and
go for it. At the moment there is no maven repository available online,
+ but this is in the works.
+ </p>
+ </section>
+
+ <section name="Install the Struts 2 Plugin">
+ Install the JsonResult? class in your struts.xml package:
+
+ <source>
+
+&lt;result-types&gt;
+ &lt;result-type name="json"
class="de.grobmeier.json.plugins.struts2.JsonResult"/&gt;
+&lt;/result-types&gt;
+ </source>
+
+ Then you can use this result type like that:
+
+ <source>
+
+&lt;action name="doSomething" class="de.grobmeier.DoSomething"&gt;
+ &lt;result type="json" /&gt;
+&lt;/action&gt;
+ </source>
+
+ The result is a json string.
+
+ Please note, everything you want in your JSON string must be
annotated with @JSON, even the Action class it self.
+
+ <source>
+
+@JSON
+class DoSomething {
+ @JSON public String myString = "test";
+ @JSON public String myString2 = "test2";
+ // GETTER necessary like getMyString()
+}
+ </source>
+
+ This will return {"myString" : "test", "myString2" : "test2"}
+
+ Fields need matching getter methods.
+
+ You can even annotate methods instead of the fields, if you
would like to to return a object created on the fly:
+
+ <source>
+
+@JSON
+class DoSomething {
+ @JSON public void blub() { return "test"; }
+}
+ </source>
+
+ This will return {"blub" : "test"}
+ </section>
+
+
+ </body>
+</document>
=======================================
--- /trunk/jjson/src/site/site.xml Fri Oct 14 02:13:36 2011
+++ /trunk/jjson/src/site/site.xml Fri Oct 14 23:20:38 2011
@@ -34,6 +34,9 @@

<menu name="${project.name}">
<item name="Home" href="index.html" />
+ <item name="Download" href="downloads.html" />
+ <item name="Install" href="install.html" />
+ <item name="Usage" href="basics.html" />
</menu>

<menu ref="reports" />
=======================================
--- /trunk/jjson/src/site/xdoc/index.xml Fri Oct 14 02:13:36 2011
+++ /trunk/jjson/src/site/xdoc/index.xml Fri Oct 14 23:20:38 2011
@@ -35,5 +35,15 @@
<li>Creating a json string out of a java object net</li>
</ul>
</section>
+
+ <section name="Why another JSon-Lib for Java?">
+ I just didn't want to have complex implementations of this simple
notation- most of the features other libs gave to me i didn't use. If you
feel the same you should consider to contact me (on the dev list) and
contribute some patches. You are welcome.
+ </section>
+
+ <section name="State of development">
+ <p>The new version should work for a lots of cases. Mapping with
annotations and working with json using the apis objects work in both
directions.</p>
+ <p>The struts 2 plugin is pretty new and has the ususal flaws.</p>
+ </section>
+
</body>
</document>

Reply all
Reply to author
Forward
0 new messages