starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

Support json_pretty() function for formatted JSON output

Open murphyatwork opened this issue 4 months ago • 4 comments

Description:

Currently, StarRocks provides json_format() to serialize JSON values, but it outputs compact one-line strings. For debugging and readability, it would be useful to support a json_pretty() function that prints JSON with indentation and line breaks, similar to PostgreSQL’s jsonb_pretty or MySQL’s JSON_PRETTY.

Example:

SELECT json_pretty('{"a":1,"b":[1,2,3]}');

Expected Output:

{
  "a": 1,
  "b": [
    1,
    2,
    3
  ]
}

murphyatwork avatar Aug 29 '25 14:08 murphyatwork

I would like to work on this, can you assign me? @murphyatwork

sanajitjana avatar Aug 31 '25 08:08 sanajitjana

Hi, I would like to work on this if possible. (Working on a university assignment ^_^)

daphnecalin avatar Sep 08 '25 18:09 daphnecalin

Hi @murphyatwork. Feel free to assign me to this!

ronkapoor86 avatar Sep 09 '25 03:09 ronkapoor86

Hi @murphyatwork and @ronkapoor86,

I checked the repository but couldn't find an open PR associated with this issue currently.

I also noticed that @daphnecalin appears to have implemented this in their personal fork. @daphnecalin, are you planning to submit a PR to the official repository?

If neither of you are working on this, I would be happy to pick it up and submit the PR.

arvindKandpal-ksolves avatar Dec 12 '25 04:12 arvindKandpal-ksolves

Hi @murphyatwork,

I have raised the PR #66695 for this feature. It includes the complete implementation (BE & FE), comprehensive tests (Unit & Regression), and documentation.

Please take a look when you have a moment. Thanks!

arvindKandpal-ksolves avatar Dec 13 '25 06:12 arvindKandpal-ksolves