Skip to content

[FEATURE] Add to_json_string function to PPL #3210

Closed

Description

@acarbonetto

Is your feature request related to a problem?

As part of the RFC to add JSON functions, the to_json_string function would be useful to convert json objects into json-encoded strings.

What solution would you like?

### `TO_JSON_STRING`

**Description**

`to_json_string(doc)` Returns a JSON string representing the given json_document object.

**Argument type:** JSON_OBJECT

**Return type:** STRING

Example:

    os> source=people | eval `json_string` = to_json_string(json_array(1, 2, 0, -1, 1.1, -0.11)) | fields json_string
    fetched rows / total rows = 1/1
    +--------------------------------+
    | json_string                    |
    +--------------------------------+
    | [1.0,2.0,0.0,-1.0,1.1,-0.11]   |
    +--------------------------------+

    os> source=people | eval `json_string` = to_json_string(json_object('key', 123.45)) | fields json_string
    fetched rows / total rows = 1/1
    +-----------------+
    | json_string     |
    +-----------------+
    | {'key', 123.45} |
    +-----------------+

What alternatives have you considered?

N/A

Do you have any additional context?

opensearch-project/opensearch-spark#870 - PR to add json objects to opensearch-spark PPL

Activity

  1. added
    PPL
    on May 29, 2025
  2. LantaoJin commented on Jun 16, 2025

    @LantaoJin
    Member

    Resolved by #3559 with Calcite implementation.

  3. moved this from Not Started to Done in PPL Trackeron Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions