array_to_Json(anyarray [,pretty_bool]) | Json | Returns the array as JsON. A Postgresql multIDimensional array becomes a JsON array of arrays. line Feeds will be added between dimension 1 elements ifpretty_boolis true. | array_to_Json('{{1,5},{99,100}}'::int[]) | [[1,5],[99,100]] |
row_to_Json(record [,255); padding:0.5ex"> Returns the row as JsON. line Feeds will be added between level 1 elements ifpretty_boolis true. | row_to_Json(row(1,'foo')) | {"f1":1,"f2":"foo"} |
to_Json(anyelement) | Returns the value as JsON. If the data type is not built in,and there is a cast from the type toJson,the cast function will be used to perform the conversion. Otherwise,for any value other than a number,a Boolean,or a null value,the text representation will be used,escaped and quoted so that it is legal JsON. | to_Json('Fred saID "Hi."'::text) | "Fred saID \"Hi.\"" |
Json_array_length(Json) | int | Returns the number of elements in the outermost JsON array. | Json_array_length('[1,3,{"f1":1,"f2":[5,6]},4]') | 5 |
Json_each(Json) | SetoF key text,value Json | Expands the outermost JsON object into a set of key/value pairs. | select * from Json_each('{"a":"foo","b":"bar"}') | key | value-----+------- a | "foo" b | "bar" |
Json_each_text(from_Json Json) | Expands the outermost JsON object into a set of key/value pairs. The returned value will be of type text. | select * from Json_each_text('{"a":"foo",255); padding:0.5ex"> key | value-----+------- a | foo b | bar |
Json_extract_path(from_Json Json,VARIADIC path_elems text[]) | Returns JsON object pointed to bypath_elems. | Json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}','f4') | {"f5":99,"f6":"foo"} |
Json_extract_path_text(from_Json Json,239); padding:0.5ex"> text | Returns JsON object pointed to bypath_elems. | Json_extract_path_text('{"f2":{"f3":1},'f4','f6') | foo |
Json_object_keys(Json) | SetoF text | Returns set of keys in the JsON object. Only the"outer"object will be displayed. | Json_object_keys('{"f1":"abc","f2":{"f3":"a","f4":"b"}}') | Json_object_keys------------------ f1 f2 |
Json_populate_record(base anyelement,from_Json Json,[,use_Json_as_text bool=false] | anyelement | Expands the object infrom_Jsonto a row whose columns match the record type defined by base. Conversion will be best effort; columns in base with no corresponding key infrom_Jsonwill be left null. If a column is specifIEd more than once,the last value is used. | select * from Json_populate_record(null::x,'{"a":1,"b":2}') | a | b---+--- 1 | 2 |
Json_populate_recordset(base anyelement,255); padding:0.5ex"> SetoF anyelement | Expands the outermost set of objects infrom_Jsonto a set whose columns match the record type defined by base. Conversion will be best effort; columns in base with no corresponding key infrom_Jsonwill be left null. If a column is specifIEd more than once,255); padding:0.5ex"> select * from Json_populate_recordset(null::x,'[{"a":1,"b":2},{"a":3,"b":4}]') | a | b---+--- 1 | 2 3 | 4 |
Json_array_elements(Json) | SetoF Json | Expands a JsON array to a set of JsON elements. | Json_array_elements('[1,true,[2,false]]') | value----------- 1 true [2,false] |
评论列表(0条)