Skip to content

Commit a98e5ae

Browse files
committed
Add json data type
1 parent 77c6d6c commit a98e5ae

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

codecs/vlen-utf8/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ For example, the array metadata below specifies that the array contains variable
2727

2828
This is a `array -> bytes` codec.
2929

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

3234
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.
3335
This prefix is followed by a sequence of encoded elements in lexicographical order.
3436
Each element in the sequence is encoded by a u32le representing the number of bytes followed by the bytes themselves.
35-
The bytes for each element are obtained by encoding the element as UTF8 bytes.
37+
38+
For the `"string"` data type, the bytes for each element are obtained by
39+
encoding the element as UTF8 bytes.
40+
41+
For the `"json"` data type, the bytes for each element are obtained by encoding
42+
the element as JSON (which is itself valid UTF8).
3643

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

data-types/json/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# json data type
2+
3+
Defines a data type for arbitrary JSON values.
4+
5+
## Permitted fill values
6+
7+
The value of the `fill_value` metadata may be any JSON value.
8+
9+
## Example
10+
11+
For example, the array metadata below specifies that the array contains JSON values:
12+
13+
```json
14+
{
15+
"data_type": "json",
16+
"fill_value": {"some": "value"},
17+
"codecs": [{
18+
"name": "vlen-utf8"
19+
}],
20+
}
21+
```
22+
23+
## Notes
24+
25+
Currently, this data type is only compatible with the [`"vlen-utf8"`](../../codecs/vlen-utf8/README.md) codec.
26+
27+
## Change log
28+
29+
No changes yet.
30+
31+
## Current maintainers
32+
33+
* Jeremy Maitin-Shepard ([@jbms](https://github.com/jbms)), Google

data-types/json/schema.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"oneOf": [
4+
{
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"const": "json"
9+
},
10+
"configuration": {
11+
"type": "object",
12+
"additionalProperties": false
13+
}
14+
},
15+
"required": ["name"],
16+
"additionalProperties": false
17+
},
18+
{ "const": "json" }
19+
]
20+
}

0 commit comments

Comments
 (0)