Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JEP-17 JSON functions (GorillaStack) #6

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions proposals/draft/jep-017-json-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# JSON Functions (GorillaStack)

|||
|---|---
| **JEP** | 17
| **Author** | Chris Armstrong (Gorilla Stack)
| **Status** | draft
| **Created**| 31-10-2019

## Abstract

This document proposes adding functions for manipulating JSON data, including
a `parse_json` and `to_json` function.

## Motivation

There is separate requirements to both parse JSON strings and to serialise
full or partial object structures to JSON.

## Specification

The following functions will be added to the specification:

### parse_json

```
any parse_json(string $json_data)
```

Parse string `$json_data` containing JSON data and produce an object structure that can be
further manipulated by JMESPath.

If the string contains invalid JSON, an error should be generated.

### to_json

```
string to_json(any $value)
```

Serialise `$value` to a JSON string. No guarantees are made about formatting - this is
implementation dependent.

## Impact

Although this introduces no changes to existing syntax or functions, it may be challenging
to support correctly in implementations other than JavaScript if the underlying language
does not contain a spec-compliant JSON parser or producing arbitrary object structures for
use with JMESPath is difficult.