Changeset: 063634c9435b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=063634c9435b
Added Files:
        monetdb5/modules/atoms/Tests/json05.mal
        monetdb5/modules/atoms/Tests/json05.stable.err
        monetdb5/modules/atoms/Tests/json05.stable.out
Modified Files:
        monetdb5/modules/atoms/Tests/All
        monetdb5/modules/atoms/Tests/json02.mal
        monetdb5/modules/atoms/Tests/json02.stable.out
        monetdb5/modules/atoms/json_atom.c
        monetdb5/modules/atoms/json_atom.h
        monetdb5/modules/atoms/json_atom.mal
Branch: default
Log Message:

A simple JSON path extractor


diffs (truncated from 533 to 300 lines):

diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -20,4 +20,5 @@ json01
 json02
 json03
 json04
+json05
 jsonrender
diff --git a/monetdb5/modules/atoms/Tests/json02.mal 
b/monetdb5/modules/atoms/Tests/json02.mal
--- a/monetdb5/modules/atoms/Tests/json02.mal
+++ b/monetdb5/modules/atoms/Tests/json02.mal
@@ -2,53 +2,53 @@
 b:= json.new("{\"f1\":1}");
 f:= json.names(b);
 io.print(f);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 
 b:= json.new("{\"f1\":1,\"f2\":2}");
 f:= json.names(b);
 io.print(f);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 
 b:= json.new("{\"f1\":1,\"f2\":2,\"f1\":3}");
 f:= json.names(b);
 io.print(f);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 
 b:= json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4]}");
 f:= json.names(b);
 io.print(f);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 i:= json.length(b);
 io.print(i);
 
 b:= json.new("[]");
 z:= json.isvalidarray(b);
 io.print(z);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 i:= json.length(b);
 io.print(i);
 
 b:= json.new("[1,\"f2\", 2]");
 z:= json.isvalidarray(b);
 io.print(z);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 
 b:= json.new("[1,2,null,true,false ]");
 z:= json.isvalidarray(b);
 io.print(z);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
 i:= json.length(b);
 io.print(i);
 
 b:= json.new("[\"\\/\" , 2 ]");
 z:= json.isvalidarray(b);
 io.print(z);
-f:= json.values(b);
-io.print(f);
+ff:= json.values(b);
+io.print(ff);
diff --git a/monetdb5/modules/atoms/Tests/json02.stable.out 
b/monetdb5/modules/atoms/Tests/json02.stable.out
--- a/monetdb5/modules/atoms/Tests/json02.stable.out
+++ b/monetdb5/modules/atoms/Tests/json02.stable.out
@@ -23,49 +23,49 @@ function user.main():void;
     b := json.new("{\"f1\":1}");
     f := json.names(b);
     io.print(f);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     b := json.new("{\"f1\":1,\"f2\":2}");
     f := json.names(b);
     io.print(f);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     b := json.new("{\"f1\":1,\"f2\":2,\"f1\":3}");
     f := json.names(b);
     io.print(f);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     b := json.new("{\"f1\":{\"f12\":3},\"f2\":[2,3,4]}");
     f := json.names(b);
     io.print(f);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     i := json.length(b);
     io.print(i);
     b := json.new("[]");
     z := json.isvalidarray(b);
     io.print(z);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     i := json.length(b);
     io.print(i);
     b := json.new("[1,\"f2\", 2]");
     z := json.isvalidarray(b);
     io.print(z);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     b := json.new("[1,2,null,true,false ]");
     z := json.isvalidarray(b);
     io.print(z);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
     i := json.length(b);
     io.print(i);
     b := json.new("[\"\\/\" , 2 ]");
     z := json.isvalidarray(b);
     io.print(z);
-    f := json.values(b);
-    io.print(f);
+    ff := json.values(b);
+    io.print(ff);
 end main;
 #-----------------#
 # h    t         # name
diff --git a/monetdb5/modules/atoms/Tests/json05.mal 
b/monetdb5/modules/atoms/Tests/json05.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/atoms/Tests/json05.mal
@@ -0,0 +1,43 @@
+js:= calc.json("[{\"book\":{ \"category\": \"reference\", \"author\": \"Nigel 
Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, \"book\":{ 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, \"book\":{ \"category\": \"fiction\", \"author\": 
\"Herman Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", 
\"price\": 8.99 }, \"book\":{ \"category\": \"fiction\", \"author\": \"J. R. R. 
Tolkien\", \"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", 
\"price\": 22.99 }, \"pencil\":{ \"color\": \"red\", \"price\": 19.95 }}]");
+
+io.print(js);
+
+p:= json.path(js,".book");
+io.print(p);
+p:= json.path(js,".pencil");
+io.print(p);
+p:= json.path(js,"pencil");
+io.print(p);
+p:= json.path(js,"..author");
+io.print(p);
+p:= json.path(js,"..category");
+io.print(p);
+
+p:= json.path(js,".book[0]");
+io.print(p);
+p:= json.path(js,".book[1]");
+io.print(p);
+p:= json.path(js,".book[2]");
+io.print(p);
+p:= json.path(js,".book[3]");
+io.print(p);
+p:= json.path(js,".book.category");
+io.print(p);
+
+js := calc.json("[[{\"name\":\"john\"}], {\"name\":\"mary\"}]");
+p := json.path(js,"..name");
+io.print(p);
+p := json.path(js,".name");
+io.print(p);
+
+#empty lists
+p:= json.path(js,".book[-1]");
+io.print(p);
+p:= json.path(js,".book[4]");
+io.print(p);
+p:= json.path(js,"$$$");
+io.print(p);
+p:= json.path(js,"...");
+io.print(p);
+p:= json.path(js,"[[2]]");
+io.print(p);
diff --git a/monetdb5/modules/atoms/Tests/json05.stable.err 
b/monetdb5/modules/atoms/Tests/json05.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/atoms/Tests/json05.stable.err
@@ -0,0 +1,29 @@
+stderr of test 'json05` in directory 'monetdb5/modules/atoms` itself:
+
+
+# 19:57:09 >  
+# 19:57:09 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35138" "--set" 
"mapi_usock=/var/tmp/mtest-2321/.s.monetdb.35138" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_atoms"
 "json05.mal"
+# 19:57:09 >  
+
+# builtin opt  gdk_dbpath = 
/export/scratch1/mk/current//Linux/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = yes
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 35138
+# cmdline opt  mapi_usock = /var/tmp/mtest-2321/.s.monetdb.35138
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbpath = 
/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_atoms
+
+# 19:57:09 >  
+# 19:57:09 >  "Done."
+# 19:57:09 >  
+
diff --git a/monetdb5/modules/atoms/Tests/json05.stable.out 
b/monetdb5/modules/atoms/Tests/json05.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/atoms/Tests/json05.stable.out
@@ -0,0 +1,83 @@
+stdout of test 'json05` in directory 'monetdb5/modules/atoms` itself:
+
+
+# 19:57:09 >  
+# 19:57:09 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=35138" "--set" 
"mapi_usock=/var/tmp/mtest-2321/.s.monetdb.35138" "--set" "monet_prompt=" 
"--forcemito" "--set" "mal_listing=2" 
"--dbpath=/export/scratch1/mk/current//Linux/var/MonetDB/mTests_monetdb5_modules_atoms"
 "json05.mal"
+# 19:57:09 >  
+
+# MonetDB 5 server v11.16.0
+# This is an unreleased version
+# Serving database 'mTests_monetdb5_modules_atoms', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 15.629 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2013 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.ins.cwi.nl:35138/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-2321/.s.monetdb.35138
+# MonetDB/GIS module loaded
+# MonetDB/JAQL module loaded
+# MonetDB/SQL module loaded
+function user.main():void;
+    js := calc.json("[{\"book\":{ \"category\": \"reference\", \"author\": 
\"Nigel Rees\", \"title\": \"Sayings of the Century\", \"price\": 8.95 }, 
\"book\":{ \"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": 
\"Sword of Honour\", \"price\": 12.99 }, \"book\":{ \"category\": \"fiction\", 
\"author\": \"Herman Melville\", \"title\": \"Moby Dick\", \"isbn\": 
\"0-553-21311-3\", \"price\": 8.99 }, \"book\":{ \"category\": \"fiction\", 
\"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the Rings\", 
\"isbn\": \"0-395-19395-8\", \"price\": 22.99 }, \"pencil\":{ \"color\": 
\"red\", \"price\": 19.95 }}]");
+    io.print(js);
+    p := json.path(js,".book");
+    io.print(p);
+    p := json.path(js,".pencil");
+    io.print(p);
+    p := json.path(js,"pencil");
+    io.print(p);
+    p := json.path(js,"..author");
+    io.print(p);
+    p := json.path(js,"..category");
+    io.print(p);
+    p := json.path(js,".book[0]");
+    io.print(p);
+    p := json.path(js,".book[1]");
+    io.print(p);
+    p := json.path(js,".book[2]");
+    io.print(p);
+    p := json.path(js,".book[3]");
+    io.print(p);
+    p := json.path(js,".book.category");
+    io.print(p);
+    js := calc.json("[[{\"name\":\"john\"}], {\"name\":\"mary\"}]");
+    p := json.path(js,"..name");
+    io.print(p);
+    p := json.path(js,".name");
+    io.print(p);
+#empty lists 
+    p := json.path(js,".book[-1]");
+    io.print(p);
+    p := json.path(js,".book[4]");
+    io.print(p);
+    p := json.path(js,"$$$");
+    io.print(p);
+    p := json.path(js,"...");
+    io.print(p);
+    p := json.path(js,"[[2]]");
+    io.print(p);
+end main;
+[ "[{\"book\":{ \"category\": \"reference\", \"author\": \"Nigel Rees\", 
\"title\": \"Sayings of the Century\", \"price\": 8.95 }, \"book\":{ 
\"category\": \"fiction\", \"author\": \"Evelyn Waugh\", \"title\": \"Sword of 
Honour\", \"price\": 12.99 }, \"book\":{ \"category\": \"fiction\", \"author\": 
\"Herman Melville\", \"title\": \"Moby Dick\", \"isbn\": \"0-553-21311-3\", 
\"price\": 8.99 }, \"book\":{ \"category\": \"fiction\", \"author\": \"J. R. R. 
Tolkien\", \"title\": \"The Lord of the Rings\", \"isbn\": \"0-395-19395-8\", 
\"price\": 22.99 }, \"pencil\":{ \"color\": \"red\", \"price\": 19.95 }}]" ]
+[ "[{ \"category\": \"reference\", \"author\": \"Nigel Rees\", \"title\": 
\"Sayings of the Century\", \"price\": 8.95 },{ \"category\": \"fiction\", 
\"author\": \"Evelyn Waugh\", \"title\": \"Sword of Honour\", \"price\": 12.99 
},{ \"category\": \"fiction\", \"author\": \"Herman Melville\", \"title\": 
\"Moby Dick\", \"isbn\": \"0-553-21311-3\", \"price\": 8.99 },{ \"category\": 
\"fiction\", \"author\": \"J. R. R. Tolkien\", \"title\": \"The Lord of the 
Rings\", \"isbn\": \"0-395-19395-8\", \"price\": 22.99 }]" ]
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to