Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
Renamed library to purest_json;
Browse files Browse the repository at this point in the history
Renamed [couchdb] to [rest-json]
  • Loading branch information
residuum committed Sep 12, 2011
1 parent a588c37 commit 4596bdf
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 269 deletions.
22 changes: 11 additions & 11 deletions Makefile
Expand Up @@ -7,31 +7,31 @@ FLAGS_MINGW = -Wall -static -ansi -O2
LIB_LINUX = -lcurl -ljson
LIB_MINGW = -lcurl -ljson

COUCHPDB_LINUX = bin/couchpdb.pd_linux
COUCHPDB_MINGW = bin/couchpdb.dll
PUREST_JSON_LINUX = bin/purest_json.pd_linux
PUREST_JSON_MINGW = bin/purest_json.dll

PD_EXE = pdextended

PDINCLUDE = -I../../../diverse/Pd-0.42.5-extended/pd/src

COUCHPDB_SRC = src/couchpdb.c
PUREST_JSON_SRC = src/purest_json.c

default: couchpdb-linux
default: purest-json-linux

all: couchpdb-linux couchpdb-mingw doc
all: purest-json-linux purest-json-mingw doc

couchpdb-test: couchpdb
$(PD_EXE) -stderr -lib bin/couchpdb couchpdb-test.pd
purest-json-test: purest-json-linux
$(PD_EXE) -stderr -lib bin/purest_json purest-json-test.pd

couchpdb-linux:
$(CC_LINUX) $(FLAGS_LINUX) $(LIB_LINUX) $(PDINCLUDE) $(COUCHPDB_SRC) -o $(COUCHPDB_LINUX)
purest-json-linux:
$(CC_LINUX) $(FLAGS_LINUX) $(LIB_LINUX) $(PDINCLUDE) $(PUREST_JSON_SRC) -o $(PUREST_JSON_LINUX)

couchpdb-mingw:
purest-json-mingw:
PATH=/usr/local/mingw/bin:$(PATH)
CPATH=/usr/local/mingw/include
LD_LIBRARY_PATH=/usr/local/mingw/lib
PKG_CONFIG_DIR=/usr/local/mingw/lib/pkgconfig
$(CC_MINGW) $(FLAGS_MINGW) $(LIB_MINGW) $(PDINCLUDE) $(COUCHPDB_SRC) -o $(COUCHPDB_MINGW)
$(CC_MINGW) $(FLAGS_MINGW) $(LIB_MINGW) $(PDINCLUDE) $(PUREST_JSON_SRC) -o $(PUREST_JSON_MINGW)

doc:
doxygen Doxyfile
77 changes: 54 additions & 23 deletions bin/json-help.pd
@@ -1,4 +1,4 @@
#N canvas 0 0 994 514 10;
#N canvas 0 0 994 506 10;
#X obj 566 321 json-encode;
#X obj 566 390 json-decode;
#X obj 47 -14 json-encode;
Expand All @@ -10,15 +10,6 @@ add adds a new key/value pair to the internally stored object. clear
clears the internally stored object. bang outputs the stored object
as a JSON string. If you call add with a value that is already a JSON
string \, then the object will be added as a nested object.;
#X text 47 118 [json-decode] will accept a JSON string at its input
and will output the decoded object as a series of lists of key/value
pairs. Boolean values of TRUE/FALSE will be translated to 1 or 0 \,
float and integer values will be output as floats. Json-decode will
try to convert string values to floats \, and if that fails \, will
output them as symbols. Nested objects and arrays will not be output.
After the object is fully parsed \, the right outlet will issue a bang
\, so that you can differenciate between subsequent objects. The messages
will come as list key value.;
#X msg 548 57 add id 1;
#X text 545 24 Will add key id and value of 1 to object;
#X msg 590 87 add name Residuum;
Expand All @@ -30,7 +21,7 @@ JSON object;
#X text 651 202 adding a different value will overwrite the previously
stored one;
#X msg 363 271 clear;
#X text 359 251 This will clear the object;
#X text 359 252 This will clear the object;
#X text 696 263 output the value;
#X msg 697 282 bang;
#X obj 656 391 print JSON string;
Expand Down Expand Up @@ -64,7 +55,7 @@ stored one;
#X connect 9 2 2 0;
#X connect 12 0 1 0;
#X connect 12 1 4 0;
#X restore 45 426 pd nested-objects;
#X restore 57 429 pd nested-objects;
#X obj 697 427 print decoding done;
#X obj 566 427 print decoded values;
#X obj 566 348 t a a;
Expand Down Expand Up @@ -133,16 +124,56 @@ JSON object is fully decoded.;
#X connect 23 0 11 0;
#X connect 24 0 0 0;
#X connect 25 0 0 0;
#X restore 161 427 pd about-decoded-json-strings;
#X connect 0 0 24 0;
#X connect 1 0 23 0;
#X connect 1 1 22 0;
#X connect 8 0 0 0;
#X restore 173 430 pd about-decoded-json-strings;
#X text 46 114 [json-decode] will accept a JSON string at its input
and will output the decoded object as a series of lists of key/value
pairs. Boolean values of TRUE/FALSE will be translated to 1 or 0 \,
float and integer values will be output as floats. Json-decode will
try to convert string values to floats \, and if that fails \, will
output them as symbols \, nested objects and arrays are output as strings
\, that can be parsed. After the object is fully parsed \, the right
outlet will issue a bang \, so that you can differenciate between subsequent
objects. The messages will come as list key value.;
#N canvas 0 0 450 465 json-arrays 0;
#X obj 42 73 json-encode;
#X msg 42 33 clear \, array storage textfile \, array storage couchdb
\, array storage array \, bang;
#X obj 42 154 json-decode;
#X obj 42 112 t a a;
#X text 49 11 This will construct a json array.;
#X obj 42 191 list trim;
#X obj 42 224 route storage;
#X obj 42 255 l2s;
#X obj 43 313 json-decode;
#X obj 43 280 t a a;
#X obj 128 313 print JSON array string;
#X obj 132 155 print JSON object string;
#X obj 106 349 print array member done;
#X obj 43 374 print decoded;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 2 0 5 0;
#X connect 3 0 2 0;
#X connect 3 1 11 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 7 0 9 0;
#X connect 8 0 13 0;
#X connect 8 1 12 0;
#X connect 9 0 8 0;
#X connect 9 1 10 0;
#X restore 364 430 pd json-arrays;
#X text 46 232 [json-decode] treats json arrays as a series of objects.
;
#X connect 0 0 23 0;
#X connect 1 0 22 0;
#X connect 1 1 21 0;
#X connect 7 0 0 0;
#X connect 9 0 0 0;
#X connect 10 0 0 0;
#X connect 11 0 0 0;
#X connect 12 0 0 0;
#X connect 13 0 0 0;
#X connect 14 0 0 0;
#X connect 16 0 0 0;
#X connect 19 0 0 0;
#X connect 24 0 1 0;
#X connect 24 1 20 0;
#X connect 15 0 0 0;
#X connect 18 0 0 0;
#X connect 23 0 1 0;
#X connect 23 1 19 0;
196 changes: 105 additions & 91 deletions bin/couchdb-help.pd → bin/rest-json-help.pd
@@ -1,6 +1,4 @@
#N canvas 0 0 1163 709 10;
#X obj 20 -60 couchdb;
#X obj 630 310 couchdb;
#N canvas 600 218 704 421 10;
#X text 76 -59 - object for communicating with a CouchDB;
#N canvas 260 56 853 470 CouchDB-basics 0;
#X text 416 71 CRUD documents:;
Expand Down Expand Up @@ -64,19 +62,28 @@ layout \, even when stored in the same table.;
#X text 17 61 RESTful interface means \, that all operations are done
with HTTP requests \, depending on the request methods \, different
actions are performed on databases and documents.;
#X msg 666 88 bang;
#X obj 17 188 couchdb http://localhost:5984/;
#X msg 422 -9 url http://localhost:5984/;
#X obj 630 345 list trim;
#X obj 629 376 route error ok;
#X msg 638 443 0;
#X obj 720 332 t b b;
#X msg 720 359 1;
#X text 558 425 Close signal flow on error;
#X obj 514 493 print error message;
#X text 779 367 Reopen signal flow after each object.;
#X obj 669 401 print OK message;
#X text 16 171 Set the base url at creation or use [url( message;
#X obj 17 243 json-decode;
#X text 18 286 When OAUTH is implemented \, you will find infos about
it here;
#X text 15 226 [couchdb] gets data as JSON objects \, output is the
same as;
#X text 17 109 For more infos on how to create \, retrieve \, update
and delete (CRUD) data \, see:;
#X obj 17 188 rest-json http://localhost:5984/;
#X obj 19 -60 rest-json;
#N canvas 0 0 811 709 couchdb 0;
#X msg 303 116 bang;
#X msg 59 19 url http://localhost:5984/;
#X obj 267 373 list trim;
#X obj 266 404 route error ok;
#X msg 275 471 0;
#X obj 357 360 t b b;
#X msg 357 387 1;
#X text 195 453 Close signal flow on error;
#X obj 151 521 print error message;
#X text 416 395 Reopen signal flow after each object.;
#X obj 306 429 print OK message;
#N canvas 576 82 450 511 create-sequencer-data 0;
#X obj 32 12 inlet;
#X obj 103 349 outlet;
Expand All @@ -99,85 +106,92 @@ add pitch 880 \, add duration 1000 \, bang \, clear \, add pitch 440
#X connect 6 1 3 1;
#X connect 7 0 2 0;
#X connect 7 0 3 0;
#X restore 666 115 pd create-sequencer-data;
#X text 421 -30 1 Sets the base URL.;
#X text 604 -34 2 Creates database pd-test on server with base URL.
#X restore 303 143 pd create-sequencer-data;
#X text 58 -2 1 Sets the base URL.;
#X text 241 -6 2 Creates database pd-test on server with base URL.
If you do not set the base URL \, then you can also issue this command
with [PUT http://localhost:5984/pd-test/(;
#X text 663 60 3 Creates some sequencer data and stores the data in
#X text 300 88 3 Creates some sequencer data and stores the data in
pd-test. Objects contain "pitch" and "duration".;
#X text 709 191 4 Start sequencer and get first object;
#X obj 710 238 f;
#X obj 738 240 + 1;
#X obj 775 452 route pitch duration;
#X obj 747 484 pack f f f;
#X obj 675 560 unpack f f f;
#X obj 744 593 del;
#X floatatom 709 595 5 0 0 0 - - -;
#X text 802 512 first inlet of pack is not used. The reason for that
#X text 346 219 4 Start sequencer and get first object;
#X obj 347 266 f;
#X obj 375 268 + 1;
#X obj 412 480 route pitch duration;
#X obj 384 512 pack f f f;
#X obj 312 588 unpack f f f;
#X obj 381 621 del;
#X floatatom 346 623 5 0 0 0 - - -;
#X text 439 540 first inlet of pack is not used. The reason for that
is explained in the help patch for;
#X obj 998 528 json-decode;
#X obj 17 243 json-decode;
#X obj 485 360 print data;
#X text 424 174 5 Get database pd-test;
#X text 382 251 6 Delete database pd-test;
#X msg 425 197 GET pdtest;
#X msg 609 30 PUT pdtest;
#X msg 666 139 PUT pdtest/\$1 \$2;
#X msg 384 269 DELETE pdtest;
#X msg 710 267 GET pdtest/\$1;
#X text 18 286 When OAUTH is implemented \, you will find infos about
it here;
#X text 421 -65 This example will create a database and store values
#X obj 635 556 json-decode;
#X obj 122 388 print data;
#X text 61 202 5 Get database pd-test;
#X text 19 279 6 Delete database pd-test;
#X msg 62 225 GET pdtest;
#X msg 246 58 PUT pdtest;
#X msg 303 167 PUT pdtest/\$1 \$2;
#X msg 21 297 DELETE pdtest;
#X msg 347 295 GET pdtest/\$1;
#X text 58 -37 This example will create a database and store values
to be used by a simple sequencer.;
#X msg 710 210 0;
#X obj 675 529 spigot 1;
#X obj 969 203 spigot;
#X obj 1002 169 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1
0 1;
#X obj 666 164 print Put command;
#X obj 598 398 t b a b;
#X text 949 153 toggle only when using sequencer;
#X msg 491 432 0;
#X text 463 409 restart GET sequence;
#X text 15 226 [couchdb] gets data as JSON objects \, output is the
same as;
#X text 17 109 For more infos on how to create \, retrieve \, update
and delete (CRUD) data \, see:;
#X connect 1 0 12 0;
#X connect 1 0 37 0;
#X connect 1 1 15 0;
#X connect 9 0 22 0;
#X connect 11 0 1 0;
#X connect 12 0 13 0;
#X connect 13 0 52 0;
#X connect 13 1 20 0;
#X connect 13 2 29 0;
#X connect 14 0 48 1;
#X msg 347 238 0;
#X obj 312 557 spigot 1;
#X obj 606 231 spigot;
#X obj 639 197 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 303 192 print Put command;
#X obj 235 426 t b a b;
#X text 586 181 toggle only when using sequencer;
#X msg 128 460 0;
#X text 100 437 restart GET sequence;
#X obj 267 338 rest-json;
#X connect 0 0 11 0;
#X connect 1 0 43 0;
#X connect 2 0 3 0;
#X connect 3 0 39 0;
#X connect 3 1 10 0;
#X connect 3 2 18 0;
#X connect 4 0 35 1;
#X connect 5 0 6 0;
#X connect 5 1 19 0;
#X connect 6 0 35 1;
#X connect 11 0 30 0;
#X connect 16 0 17 0;
#X connect 16 0 32 0;
#X connect 17 0 16 1;
#X connect 18 0 19 1;
#X connect 18 1 19 2;
#X connect 19 0 35 0;
#X connect 20 1 22 0;
#X connect 20 2 21 0;
#X connect 21 0 36 0;
#X connect 28 0 43 0;
#X connect 29 0 43 0;
#X connect 30 0 38 0;
#X connect 30 0 43 0;
#X connect 31 0 43 0;
#X connect 32 0 43 0;
#X connect 34 0 16 0;
#X connect 35 0 20 0;
#X connect 36 0 16 0;
#X connect 37 0 36 1;
#X connect 39 0 41 0;
#X connect 39 1 8 0;
#X connect 39 2 4 0;
#X connect 41 0 36 0;
#X connect 43 0 2 0;
#X connect 43 0 25 0;
#X connect 43 1 5 0;
#X restore 25 379 pd couchdb;
#X obj 458 216 rest-json;
#X obj 457 300 print data;
#X text 24 343 Here is a complex example for using [rest-json] to communicate
with CouchDB. It uses GET \, POST and DELETE request methods. [rest-json]
also supports POST requests.;
#X msg 337 89 GET http://search.twitter.com/search.json?q=%23puredata
;
#X msg 346 129 GET https://ajax.googleapis.com/ajax/services/search/web?v=2.0&q=puredata
;
#X connect 15 0 16 0;
#X connect 15 1 30 0;
#X connect 16 0 48 1;
#X connect 22 0 42 0;
#X connect 27 0 28 0;
#X connect 27 0 44 0;
#X connect 28 0 27 1;
#X connect 29 0 30 1;
#X connect 29 1 30 2;
#X connect 30 0 48 0;
#X connect 31 1 33 0;
#X connect 31 2 32 0;
#X connect 32 0 49 0;
#X connect 40 0 1 0;
#X connect 41 0 1 0;
#X connect 42 0 1 0;
#X connect 42 0 51 0;
#X connect 43 0 1 0;
#X connect 44 0 1 0;
#X connect 47 0 27 0;
#X connect 48 0 31 0;
#X connect 49 0 27 0;
#X connect 50 0 49 1;
#X connect 52 0 54 0;
#X connect 52 1 18 0;
#X connect 52 2 14 0;
#X connect 54 0 49 0;
#X connect 18 0 15 0;
#X connect 19 0 15 0;

0 comments on commit 4596bdf

Please sign in to comment.