mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-21 08:39:46 +08:00
9f78be8bb8
A number of other packages that read/write Zarr insert attributes whose value is a dictionary containing specialized information. An example is the GDAL Driver convention (see https://gdal.org/drivers/raster/zarr.html). In order to handle such attributes, this PR enforces a special convention. It applies to both pure Zarr an NCZarr format as written by the netdf-c library. The convention is as follows: ## Reading Suppose an attribute is read from *.zattrs* and it has a JSON value that is a a dictionary. In this case, the JSON dictionary is converted to a string value. It then appears in the netcdf-c API as if it is a character valued attribute of the same name, and whose value is the "stringified" dictionary. # Writing Suppose an attribute is of type character and its *value* *looks like* a JSON dictionary. In this case, it is parsed to JSON and written as the value of the attribute in the NCZarr file. Here the *value* is the concatenation of all the characters in the attributes netcdf-c value. The term "looks like" means that the *value*'s first character is "{", its last value is "}", and it can be successfully parsed by a JSON parser. A test case, *nczarr_test/run_jsonconventions.sh* was also added. ## Misc. Unrelated Changes 1. Fix an error in nc_test4/tst_broken_files.c 2. Modify the internal JSON parser API. 3. Modify the nczarr_test/zisjson program is modified to support this convention.
14 lines
268 B
Plaintext
14 lines
268 B
Plaintext
netcdf tmp_jsonconvention {
|
|
dimensions:
|
|
d1 = 1 ;
|
|
variables:
|
|
int v(d1) ;
|
|
v:varconvention = "{\n\"key1\": [1,2,3], \"key2\": {\"key3\": \"abc\"}}" ;
|
|
|
|
// global attributes:
|
|
:grpconvention = "{\"key1\": [1,2,3], \n\"key2\": {\"key3\": \"abc\"}}" ;
|
|
data:
|
|
|
|
v = _ ;
|
|
}
|