diff --git a/doc/json_accessors.md b/doc/json_accessors.md index 6f91a45..cfab266 100644 --- a/doc/json_accessors.md +++ b/doc/json_accessors.md @@ -115,16 +115,6 @@ Example: select json_array_to_object_array('[{"foo":42}, {"bar":[]}]') = array['{"foo":42}','{"bar":[]}'] -#### json_array_to_multi_array(text) -> text[] - -_Experimental_ - -Converts a JSON array of any depth (single or multidimensional) to a PG multidimensional array. Original JSON must contains only arrays, objects are not allowed. - -Example: - - select json_array_to_multi_array('[["foo", "bar"], []]') = array[['foo','bar'], []]; - #### json_array_to_text_array(text) -> text[] Converts a JSON array of text objects to PG array `text[]`. @@ -169,16 +159,6 @@ Example: select json_get_object_array('{"key" : [{"foo":42}, {"bar":[]}]}', 'key') = array['{"foo":42}','{"bar":[]}']; -#### json_get_multi_array(text, text) -> text[] - -_Experimental_ - -Extract and converts a JSON array of JSON arrays to PG array of text arrays `text[]`. - -Example: - - select json_get_multi_array('{"key" : [["foo", "bar"], []] }', 'key') = array[['foo','bar'], []]; - #### json_get_text_array(text, text) -> text[] Extract and converts a JSON array of text objects to PG array `text[]`. diff --git a/sql/json_accessors.sql b/sql/json_accessors.sql index 8b49a0a..e5b7864 100644 --- a/sql/json_accessors.sql +++ b/sql/json_accessors.sql @@ -34,9 +34,6 @@ create or replace function json_get_timestamp(text, text) returns timestamp with create or replace function json_array_to_object_array(text) returns text[] as 'MODULE_PATHNAME' language C immutable strict; -create or replace function json_array_to_multi_array(text) returns text[] - as 'MODULE_PATHNAME' language C immutable strict; - create or replace function json_array_to_text_array(text) returns text[] as 'MODULE_PATHNAME' language C immutable strict; @@ -60,9 +57,6 @@ create or replace function json_array_to_timestamp_array(text) returns timestamp create or replace function json_get_object_array(text, text) returns text[] as 'MODULE_PATHNAME' language C immutable strict; -create or replace function json_get_multi_array(text, text) returns text[] - as 'MODULE_PATHNAME' language C immutable strict; - create or replace function json_get_text_array(text, text) returns text[] as 'MODULE_PATHNAME' language C immutable strict; diff --git a/src/json_accessors.c b/src/json_accessors.c index 9e1968d..b89db91 100644 --- a/src/json_accessors.c +++ b/src/json_accessors.c @@ -85,7 +85,6 @@ Datum json_get_numeric(PG_FUNCTION_ARGS); Datum json_get_timestamp(PG_FUNCTION_ARGS); Datum json_array_to_object_array(PG_FUNCTION_ARGS); -Datum json_array_to_multi_array(PG_FUNCTION_ARGS); Datum json_array_to_text_array(PG_FUNCTION_ARGS); Datum json_array_to_boolean_array(PG_FUNCTION_ARGS); Datum json_array_to_int_array(PG_FUNCTION_ARGS); @@ -94,7 +93,6 @@ Datum json_array_to_numeric_array(PG_FUNCTION_ARGS); Datum json_array_to_timestamp_array(PG_FUNCTION_ARGS); Datum json_get_object_array(PG_FUNCTION_ARGS); -Datum json_get_multi_array(PG_FUNCTION_ARGS); Datum json_get_text_array(PG_FUNCTION_ARGS); Datum json_get_boolean_array(PG_FUNCTION_ARGS); Datum json_get_int_array(PG_FUNCTION_ARGS); @@ -116,7 +114,6 @@ PG_FUNCTION_INFO_V1(json_get_numeric); PG_FUNCTION_INFO_V1(json_get_timestamp); PG_FUNCTION_INFO_V1(json_array_to_object_array); -PG_FUNCTION_INFO_V1(json_array_to_multi_array); PG_FUNCTION_INFO_V1(json_array_to_text_array); PG_FUNCTION_INFO_V1(json_array_to_boolean_array); PG_FUNCTION_INFO_V1(json_array_to_int_array); @@ -125,7 +122,6 @@ PG_FUNCTION_INFO_V1(json_array_to_numeric_array); PG_FUNCTION_INFO_V1(json_array_to_timestamp_array); PG_FUNCTION_INFO_V1(json_get_object_array); -PG_FUNCTION_INFO_V1(json_get_multi_array); PG_FUNCTION_INFO_V1(json_get_text_array); PG_FUNCTION_INFO_V1(json_get_boolean_array); PG_FUNCTION_INFO_V1(json_get_int_array); @@ -538,12 +534,6 @@ Datum json_array_to_object_array(PG_FUNCTION_ARGS) return json_array_to_array_generic_args(fcinfo, CJSON_TYPE_ANY, TEXTOID, extract_json_to_string); } -Datum json_array_to_multi_array(PG_FUNCTION_ARGS) -{ - // TODO convert to multidim - return json_array_to_array_generic_args(fcinfo, CJSON_TYPE_ANY, TEXTOID, extract_json_to_string); -} - Datum json_array_to_text_array(PG_FUNCTION_ARGS) { return json_array_to_array_generic_args(fcinfo, cJSON_String, TEXTOID, extract_json_string); @@ -589,12 +579,6 @@ Datum json_get_object_array(PG_FUNCTION_ARGS) return json_object_get_generic_args(fcinfo, cJSON_Array, extract_object_array); } -Datum json_get_multi_array(PG_FUNCTION_ARGS) -{ - // TODO convert to multidim - return json_object_get_generic_args(fcinfo, cJSON_Array, extract_object_array); -} - Datum json_get_text_array(PG_FUNCTION_ARGS) { return json_object_get_generic_args(fcinfo, cJSON_Array, extract_text_array); diff --git a/test/expected/regress.out b/test/expected/regress.out index efee2c6..e7b7778 100644 --- a/test/expected/regress.out +++ b/test/expected/regress.out @@ -87,9 +87,6 @@ baz2 -- {"{\"foo\":42}","{\"bar\":[]}"} select json_array_to_object_array('[{"foo":42}, {"bar":[]}]'); {"{\"foo\":42}","{\"bar\":[]}"} --- {"[\"foo\",\"bar\"]",[]} -select json_array_to_multi_array('[["foo", "bar"], []]'); -{"[\"foo\",\"bar\"]",[]} -- {"{\"foo\":42}","{\"bar\":[]}"} select json_get_object_array('{"key" : [{"foo":42}, {"bar":[]}]}', 'key'); {"{\"foo\":42}","{\"bar\":[]}"} diff --git a/test/sql/regress.sql b/test/sql/regress.sql index eed1027..9be4d9c 100644 --- a/test/sql/regress.sql +++ b/test/sql/regress.sql @@ -67,9 +67,6 @@ select (json_array_to_text_array(json_get_object('{"foo":"qq", "bar": ["baz1", " -- {"{\"foo\":42}","{\"bar\":[]}"} select json_array_to_object_array('[{"foo":42}, {"bar":[]}]'); --- {"[\"foo\",\"bar\"]",[]} -select json_array_to_multi_array('[["foo", "bar"], []]'); - -- {"{\"foo\":42}","{\"bar\":[]}"} select json_get_object_array('{"key" : [{"foo":42}, {"bar":[]}]}', 'key');