Changeset: 4530d12232c2 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4530d12232c2 Added Files: sql/scripts/40_json.sql Modified Files: monetdb5/modules/atoms/json_atom.mal Branch: default Log Message:
The proposed SQL interface for JSON The first batch of operations is geared at simple decomposition and recomposition of the JSON structure in an SQL context diffs (71 lines): diff --git a/monetdb5/modules/atoms/json_atom.mal b/monetdb5/modules/atoms/json_atom.mal --- a/monetdb5/modules/atoms/json_atom.mal +++ b/monetdb5/modules/atoms/json_atom.mal @@ -72,4 +72,10 @@ comment "Expands the outermost JSON valu command prelude() address JSONprelude; +pattern renderobject(val:any...):json +address JSONrenderobject; + +pattern renderarray(val:any...):json +address JSONrenderobject; + json.prelude(); diff --git a/sql/scripts/40_json.sql b/sql/scripts/40_json.sql new file mode 100644 --- /dev/null +++ b/sql/scripts/40_json.sql @@ -0,0 +1,52 @@ + +-- The contents of this file are subject to the MonetDB Public License +-- Version 1.1 (the "License"); you may not use this file except in +-- compliance with the License. You may obtain a copy of the License at +-- http://www.monetdb.org/Legal/MonetDBLicense +-- +-- Software distributed under the License is distributed on an "AS IS" +-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +-- License for the specific language governing rights and limitations +-- under the License. +-- +-- The Original Code is the MonetDB Database System. +-- +-- The Initial Developer of the Original Code is CWI. +-- Copyright August 2008-2013 MonetDB B.V. +-- All Rights Reserved. + +-- (co) Martin Kersten +-- The JSON type comes with a few operators. + +create type json external name json; + +-- access the top level key by name, return its value +create function json_filter(js json, name string) +returns json external name json.filter; + +-- test string for JSON compliancy +create function json_isvalid(js string) +returns bool external name json.isvalid; + +create function json_isvalidobject(js string) +returns bool external name json.isvalidobject; + +create function json_isvalidarray(js string) +returns bool external name json.isvalidarray; + +-- return the number of primary components +create function json_length(js json) +returns integer external name json.length; + +-- unnesting the JSON structure +create function json_names(js json) +returns table ( name string) external json.names; + +create function json_values(js json) +returns table ( val string) external json.values; + +-- rendering functions +create function json_object(*) +returns json external name json.objectrender; +create function json_array(*) +returns json external name json.arrayrender; _______________________________________________ checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
