1. JsonObject is now a subclass of Dictionary instead of Object. So
there is no need to implement the Dictionary interface.
2. Fix for converting Unicode characters to \uNNNN format (missing
padding to 4 characters)
No further changes
The SCouchDB project contains more changes in the copy of the JSON package.
I did not go further in merging because in SCouchDB / JSON-rh.32
Radoslav Hodnicak introduces an instance variable 'converter'
which is initialized to
converter := UTF8TextConverter new
Igor Stasenko, Levente Uzonyi and Hannes Hirzel agreed that the UTF8
conversion does not belong into the JSON package
You only need to convert the characters to UTF-8, because you're
sending them over the network to a server, and Unicode characters have
to be converted to bytes someway. So the JSON printer shouldn't do any
conversion by default except for escaping. The only problem is that
escaping is not done as the spec requires it, but that's easy to fix.
A string is a collection of zero or more Unicode characters, wrapped
in double quotes, using backslash escapes. A character is represented
as a single character string. A string is very much like a C or Java
string.
About escaping Unicode characters
Actually escaping Unicode characters to
\uNNNN
is not necessary for characters with codes >127 in case of an upload
to a CouchDB. But this version does it.
In case you want to patch this change method
Json class escapeForCharacter: c
So the updated test case for working with WebClient, JSON and the
couchDB is the following.
| json couchDBurl |
json := JsonObject new.
json title: 'The title of my note card'.
json body: 'The body test text of my note card with some Unicode
test characters ',
(8450 asCharacter asString, 'ä.', Character cr).
"Note: JsonObject behaves like a JavaScript object insofar that you
can add properties to instances without the necessity that they have
been declared as instance variables. But you might just as well use
JsonObject like a Dictionary instead as it is a subclass of
Dictionary."