<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>Recent changes to Home</description><atom:link href="https://sourceforge.net/p/jsonunicode/wiki/Home/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 07 Jan 2014 19:33:20 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/jsonunicode/wiki/Home/feed" rel="self" type="application/rss+xml"/><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v15
+++ v16
@@ -133,8 +133,6 @@
         try (OutputStream out = new FileOutputStream(destination);
              Writer writer = JsonIo.newJsonWriter(out)) {
           data.writeJSONString(writer);
-          StringWriter sw = new StringWriter();
-          data.writeJSONString(sw);
         }
       }
     }
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 19:33:20 -0000</pubDate><guid>https://sourceforge.netbcc4eb77acec95e83403d182a2f98ee04634d2fc</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v14
+++ v15
@@ -12,6 +12,8 @@
 &gt;      xx 00 00 00  UTF-32LE
 &gt;      xx 00 xx 00  UTF-16LE
 &gt;      xx xx xx xx  UTF-8
+
+ ---

 jsonunicode for Java
 ====================
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 19:31:28 -0000</pubDate><guid>https://sourceforge.net1edcdb56f791ade0cd52b58c6052c09486334bbe</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v13
+++ v14
@@ -7,11 +7,11 @@

 &gt; Since the first two characters of a JSON text will always be ASCII characters, it is possible to determine whether an octet stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the pattern of nulls in the first four octets.

-&gt;    00 00 00 xx  UTF-32BE
-&gt;    00 xx 00 xx  UTF-16BE
-&gt;    xx 00 00 00  UTF-32LE
-&gt;    xx 00 xx 00  UTF-16LE
-&gt;    xx xx xx xx  UTF-8
+&gt;      00 00 00 xx  UTF-32BE
+&gt;      00 xx 00 xx  UTF-16BE
+&gt;      xx 00 00 00  UTF-32LE
+&gt;      xx 00 xx 00  UTF-16LE
+&gt;      xx xx xx xx  UTF-8

 jsonunicode for Java
 ====================
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 19:29:59 -0000</pubDate><guid>https://sourceforge.net8e01ebaf9ea34fdd434ae904ebb28aa73a99d4f8</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v12
+++ v13
@@ -1,7 +1,22 @@
+JSON file encoding
+==================
+
+From [RFC 4627](http://tools.ietf.org/html/rfc4627#section-3):
+
+&gt; JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
+
+&gt; Since the first two characters of a JSON text will always be ASCII characters, it is possible to determine whether an octet stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the pattern of nulls in the first four octets.
+
+&gt;    00 00 00 xx  UTF-32BE
+&gt;    00 xx 00 xx  UTF-16BE
+&gt;    xx 00 00 00  UTF-32LE
+&gt;    xx 00 xx 00  UTF-16LE
+&gt;    xx xx xx xx  UTF-8
+
 jsonunicode for Java
 ====================

-JSON documents are generally encoded in UTF-8. For some sets of character data, UTF-16 documents are smaller. JSON also supports UTF-32.
+JSON documents are generally encoded in UTF-8. For some sets of character data, UTF-16 documents are smaller.

 Some JSON APIs support parsing from byte streams. Others only work from character data and rely on the developer to handle character encoding concerns.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 19:29:18 -0000</pubDate><guid>https://sourceforge.net59728b26e43c88d797f037ec5f06dde3a2ca92cd</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v11
+++ v12
@@ -21,6 +21,13 @@
  - [Home page](http://jsonunicode.sf.net)
  -- [javadoc](http://jsonunicode.sf.net/apidocs/index.html)

+[jsonunicode-1.0.jar](http://search.maven.org/remotecontent?filepath=net/sf/jsonunicode/jsonunicode/1.0/jsonunicode-1.0.jar) is available from Maven central; add this dependency to your _pom_ file:
+
+    
+      net.sf.jsonunicode
+      jsonunicode
+      1.0
+    

  ---

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 19:25:44 -0000</pubDate><guid>https://sourceforge.netfb36ac7781d6a2ce05c38cf2655b6d2ff0861a1d</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v10
+++ v11
@@ -19,8 +19,7 @@
 =========

  - [Home page](http://jsonunicode.sf.net)
-
-TODO
+ -- [javadoc](http://jsonunicode.sf.net/apidocs/index.html)

  ---
@@ -35,17 +34,142 @@
 Gson
 ----

-TODO
+Command-line application:
+
+    import com.google.gson.Gson;
+    import net.sf.jsonunicode.JsonIo;
+    import java.io.*;
+
+    /**
+     * Gson usage demo (Java 7 syntax)
+     */
+    public class GsonIncrement {
+      public static void main(String... args) throws IOException {
+        File source = new File(args[0]);
+        File destination = new File(args[1]);
+        Data data = read(source);
+        data.value++;
+        write(data, destination);
+      }
+
+      public static Data read(File source) throws IOException {
+        try (InputStream in = new FileInputStream(source);
+             Reader reader = JsonIo.newJsonReader(in)) {
+          return new Gson().fromJson(reader, Data.class);
+        }
+      }
+
+      public static void write(Data data, File destination) throws IOException {
+        try (OutputStream out = new FileOutputStream(destination);
+             Writer writer = JsonIo.newJsonWriter(out)) {
+          new Gson().toJson(data, writer);
+        }
+      }
+
+      public static class Data {
+        public int value;
+      }
+    }
+

 JSON.simple
 -----------

-TODO
+Command-line application:
+
+    import net.sf.jsonunicode.JsonIo;
+    import org.json.simple.JSONObject;
+    import org.json.simple.parser.JSONParser;
+    import org.json.simple.parser.ParseException;
+    import java.io.*;
+
+    /**
+     * JSON.simple usage demo (Java 7 syntax)
+     */
+    public class SimpleIncrement {
+      public static void main(String... args) throws IOException {
+        File source = new File(args[0]);
+        File destination = new File(args[1]);
+        JSONObject data = read(source);
+        Number value = (Number) data.get("value");
+        data.put("value", value.doubleValue() + 1);
+        write(data, destination);
+      }
+
+      public static JSONObject read(File source) throws IOException {
+        try (InputStream in = new FileInputStream(source);
+             Reader reader = JsonIo.newJsonReader(in)) {
+          return (JSONObject) new JSONParser().parse(reader);
+        } catch (ParseException e) {
+          throw new IOException(e);
+        }
+      }
+
+      public static void write(JSONObject data, File destination) throws IOException {
+        try (OutputStream out = new FileOutputStream(destination);
+             Writer writer = JsonIo.newJsonWriter(out)) {
+          data.writeJSONString(writer);
+          StringWriter sw = new StringWriter();
+          data.writeJSONString(sw);
+        }
+      }
+    }

 org.json
 --------

-TODO
+Load, update + save same file:
+
+    import net.sf.jsonunicode.JsonIo;
+    import org.json.JSONObject;
+    import org.json.JSONTokener;
+    import java.io.*;
+
+    /**
+     * JSON.org API usage demo (Java 6 syntax)
+     */
+    public class JsonDroid {
+      public static void increment(File json) throws IOException {
+        JSONObject data = read(json);
+        Number value = (Number) data.get("value");
+        data.put("value", value.doubleValue() + 1);
+        write(data, json);
+      }
+
+      public static JSONObject read(File source) throws IOException {
+        InputStream in = new FileInputStream(source);
+        Closeable res = in;
+        try {
+          Reader reader = JsonIo.newJsonReader(in);
+          res = reader;
+          return (JSONObject) new JSONTokener(all(reader)).nextValue();
+        } finally {
+          res.close();
+        }
+      }
+
+      public static void write(JSONObject data, File destination) throws IOException {
+        OutputStream out = new FileOutputStream(destination);
+        Closeable res = out;
+        try {
+          Writer writer = JsonIo.newJsonWriter(out);
+          res = writer;
+          writer.write(data.toString());
+        } finally {
+          res.close();
+        }
+      }
+
+      private static String all(Reader from) throws IOException {
+        StringBuilder result = new StringBuilder();
+        char[] buffer = new char[1024];
+        int len;
+        while ((len = from.read(buffer)) != -1) {
+          result.append(buffer, 0, len);
+        }
+        return result.toString();
+      }
+    }

  ---

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Tue, 07 Jan 2014 17:36:09 -0000</pubDate><guid>https://sourceforge.net4b5f8db227fd19d0aacb2708503dd700406a79df</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v9
+++ v10
@@ -28,12 +28,9 @@
 Sample code
 =============

-TODO
+    {"value":1}

-JSON document
--------------
-
-TODO
+All the sample classes below read a JSON document of the above form, increment the value by one, and write the result.

 Gson
 ----
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Sun, 05 Jan 2014 18:15:02 -0000</pubDate><guid>https://sourceforge.neta72243f93c4d0c701713570b64e5b46c9db3ff79</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v8
+++ v9
@@ -4,8 +4,6 @@
 JSON documents are generally encoded in UTF-8. For some sets of character data, UTF-16 documents are smaller. JSON also supports UTF-32.

 Some JSON APIs support parsing from byte streams. Others only work from character data and rely on the developer to handle character encoding concerns.
-
-WORK IN PROGRESS

 __jsonunicode__ is a small Java API for determining the character encoding of an arbitrary JSON document. The [JSON specification](http://tools.ietf.org/html/rfc4627#section-3) defines how character encoding is handled.

@@ -35,16 +33,22 @@
 JSON document
 -------------

+TODO
+
 Gson
 ----
+
+TODO

 JSON.simple
 -----------

+TODO
+
 org.json
 --------

-
+TODO

  ---

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Sun, 05 Jan 2014 16:54:16 -0000</pubDate><guid>https://sourceforge.netf25abf3990a82a08ad01f83a2c3cda95842c977a</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v7
+++ v8
@@ -4,6 +4,8 @@
 JSON documents are generally encoded in UTF-8. For some sets of character data, UTF-16 documents are smaller. JSON also supports UTF-32.

 Some JSON APIs support parsing from byte streams. Others only work from character data and rely on the developer to handle character encoding concerns.
+
+WORK IN PROGRESS

 __jsonunicode__ is a small Java API for determining the character encoding of an arbitrary JSON document. The [JSON specification](http://tools.ietf.org/html/rfc4627#section-3) defines how character encoding is handled.

@@ -15,8 +17,39 @@

  ---

-Common errors that may indicate this library is required
-========================================================
+Resources
+=========
+
+ - [Home page](http://jsonunicode.sf.net)
+
+TODO
+
+
+ ---
+
+Sample code
+=============
+
+TODO
+
+JSON document
+-------------
+
+Gson
+----
+
+JSON.simple
+-----------
+
+org.json
+--------
+
+
+
+ ---
+
+Example errors that may indicate this library is required
+=========================================================

 Trying to decode with the incorrect encoding may result in errors of the following types.

@@ -50,17 +83,3 @@
       at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
       at org.json.JSONTokener.nextValue(JSONTokener.java:387)
       
-
- ---
-
-Example usage
-=============
-
-TODO
-
- ---
-
-Files
-=====
-
-TODO
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Sun, 05 Jan 2014 16:53:21 -0000</pubDate><guid>https://sourceforge.net124f8fd954b80252e2881ea8795d3aeede95a700</guid></item><item><title>Home modified by McDowell</title><link>https://sourceforge.net/p/jsonunicode/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -12,6 +12,8 @@
  - [Gson](http://code.google.com/p/google-gson/)
  - [JSON.simple](http://code.google.com/p/json-simple/)
  - The Android [org.json](http://developer.android.com/reference/org/json/package-summary.html) package
+
+ ---

 Common errors that may indicate this library is required
 ========================================================
@@ -49,11 +51,15 @@
       at org.json.JSONTokener.nextValue(JSONTokener.java:387)
       

+ ---
+
 Example usage
 =============

 TODO

+ ---
+
 Files
 =====

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">McDowell</dc:creator><pubDate>Sat, 04 Jan 2014 12:30:18 -0000</pubDate><guid>https://sourceforge.nete323170fcca0f23aa5bb7da7074683945689df07</guid></item></channel></rss>