Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
WebClient, JSON and couchDB
Last updated at 2:36 pm UTC on 29 January 2017
A 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 about JsonObject

"create couchDB instance"
 couchDBurl := 'http://localhost:5984/notes'.

 WebClient httpPut: couchDBurl
                 content: ''
                 type: 'text/plain'.

"Store first document"
 WebClient httpPut: couchDBurl, '/myNote1'
                 content: json asJsonString
                 type: 'text/plain'.

"You get the document back with"

 WebClient httpGet: couchDBurl, '/myNote1' .

So far so good. This solution however still escapes code points > 127.