Provides some helpers for JSON data structures.
- Version history
Utilities for accessing data structures loaded or generated by, other, JSON libraries, such as medea. Where a JSON Array is a vector and an Object is a hash-table or alist. Note that a vector does not preserve the sparse nature of a JSON Array.
This library is not agnostic to the JSON representation. The json egg, for example, preserves the sparse nature of the JSON Array by using a list. And an Object is represented by a (vector-of (pair symbol *)).
- (or vector hash-table alist) ; JSON collection
- (or fixnum string symbol) ; JSON key
- 'symbol or 'string
The acceptable JSON key for an Object depends on (json-keyform) and the index for an Array must resolve (symbol->string->real->floor->exact) to a fixnum.
- json-undefined #!optional UNDEFparameter
- json-keyform #!optional KEYFORMparameter
- default 'symbol
- json-keyform? Xprocedure
Is X a valid KEYFORM value?
- json-array? Xprocedure
Is X a vector?
- json-object? Xprocedure
Is X a hash-table or an alist?
- json-collection? Xprocedure
Is X a json-array or json-object?
- json-count JSONprocedure
Returns the number of elements in the JSON.
- json-ref JSON KEY ...procedure
Returns the value in the JSON at the reference path KEY ....
- json-fold JSON FUNCprocedure
- (KEY VAL ACC -> *)
- json-map JSON FUNCprocedure
- (KEY VAL ACC -> *)
- json-for-each JSON PROCprocedure
- (KEY VAL -> void)
- json-foldl JSON FUNC *procedure
- (ACC KEY VAL -> *)
- For now please see the "tests" directory in the egg source.
- For now the use of a vector does not preserve the sparse nature of a JSON Array. A JSON reader/writer that used the sparse-vectors egg would be useful.
This egg is hosted on the CHICKEN Subversion repository:
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
- Add json-keyform?
Copyright (C) 2022 Kon Lovett. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.