Help Center > > Developer Guide> SQL Reference> Functions and Operators> JSON Functions

JSON Functions

Updated at: Jul 15, 2020 GMT+08:00

JSON functions are used to generate JSON data (see JSON Types).

  • array_to_json(anyarray [, pretty_bool])

    Description: Returns the array as JSON. A multi-dimensional array becomes a JSON array of arrays. Line feeds will be added between dimension-1 elements if pretty_bool is true.

    Return type: json

    For example:

    1
    2
    3
    4
    5
    SELECT array_to_json('{{1,5},{99,100}}'::int[]);
    array_to_json
    ------------------
    [[1,5],[99,100]]
    (1 row)
    
  • row_to_json(record [, pretty_bool])

    Description: Returns the row as JSON. Line feeds will be added between level-1 elements if pretty_bool is true.

    Return type: json

    For example:

    1
    2
    3
    4
    5
    SELECT row_to_json(row(1,'foo'));
         row_to_json     
    ---------------------
     {"f1":1,"f2":"foo"}
    (1 row)
    

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel