generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem?
As part of the RFC to add JSON functions, the json_valid function would be useful to validate incoming json-encoded strings.
- META RFC: [META]Add PPL
JSONextended functions support #3027 - PPL RFC: [RFC] Add PPL
JSONextended functions support #3028 - Related Spark PPL PR: Support PPL
JSONfunctions: construction and extraction opensearch-spark#780
What solution would you like?
Note: The Jackson data-bind library is already available in opensearch-sql to validate json-encoded strings.
### `JSON_VALID`
**Description**
`json_valid(jsonStr)` Evaluates whether a json-encoded string contains valid JSON syntax and returns TRUE or FALSE.
**Argument type:** STRING
**Return type:** BOOLEAN
Example:
os> source=people | eval `valid_json` = json_valid('[1,2,3,4]'), `invalid_json` = json_valid('{"invalid": "json"') | fields `valid_json`, `invalid_json`
fetched rows / total rows = 1/1
+--------------+----------------+
| valid_json | invalid_json |
+--------------+----------------+
| True | False |
+--------------+----------------+
os> source=accounts | where json_valid('[1,2,3,4]') and isnull(email) | fields account_number, email
fetched rows / total rows = 1/1
+------------------+---------+
| account_number | email |
|------------------+---------|
| 13 | null |
+------------------+---------+
What alternatives have you considered?
N/A
Do you have any additional context?
opensearch-project/opensearch-spark#780 - PR to add feature to opensearch-spark PPL
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request