Skip to content

Add json data type #9

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions codecs/vlen-utf8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ For example, the array metadata below specifies that the array contains variable

This is a `array -> bytes` codec.

This codec is only compatible with the [`"string"`](../../data-types/string/README.md) data type.
This codec is only compatible with the
[`"string"`](../../data-types/string/README.md) and
[`"json"`](../../data-types/json/README.md) data types.

In the encoded format, each chunk is prefixed with a 32-bit little-endian unsigned integer (u32le) that specifies the number of elements in the chunk.
This prefix is followed by a sequence of encoded elements in lexicographical order.
Each element in the sequence is encoded by a u32le representing the number of bytes followed by the bytes themselves.
The bytes for each element are obtained by encoding the element as UTF8 bytes.

For the `"string"` data type, the bytes for each element are obtained by
encoding the element as UTF8 bytes.

For the `"json"` data type, the bytes for each element are obtained by encoding
the element as JSON (which is itself valid UTF8).

See https://numcodecs.readthedocs.io/en/stable/other/vlen.html#vlenutf8 for details about the encoding.

Expand Down
33 changes: 33 additions & 0 deletions data-types/json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# json data type

Defines a data type for arbitrary JSON values.

## Permitted fill values

The value of the `fill_value` metadata may be any JSON value.

## Example

For example, the array metadata below specifies that the array contains JSON values:

```json
{
"data_type": "json",
"fill_value": {"some": "value"},
"codecs": [{
"name": "vlen-utf8"
}],
}
```

## Notes

Currently, this data type is only compatible with the [`"vlen-utf8"`](../../codecs/vlen-utf8/README.md) codec.

## Change log

No changes yet.

## Current maintainers

* Jeremy Maitin-Shepard ([@jbms](https://github.com/jbms)), Google
20 changes: 20 additions & 0 deletions data-types/json/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "object",
"properties": {
"name": {
"const": "json"
},
"configuration": {
"type": "object",
"additionalProperties": false
}
},
"required": ["name"],
"additionalProperties": false
},
{ "const": "json" }
]
}