The jsown-utils Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The jsown-utils Reference Manual

This is the jsown-utils Reference Manual, version 0.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 05:09:20 2022 GMT+0.

Table of Contents


1 Introduction

jsown-utils

jsown-utils is utilities for Common Lisp JSON library jsown, to pretty print JSON and so on.


License

Copyright(c) 2017 Muyinliu Xing Released under the ISC License.


Dependencies


Install and load with QuickLisp

In shell:

git clone https://github.com/muyinliu/jsown-utils.git
cp -r jsown-utils ~/quicklisp/local-projects/jsown-utils

Then in Common Lisp:

(ql:quickload 'jsown-utils)

Usage

pretty print utils

jsown:pprint-json, pretty print JSON

(jsown:pprint-json "{\"HeWeather5\":[{\"basic\":{\"city\":\"北京\",\"cnty\":\"中国\",\"id\":\"CN101010100\",\"lat\":\"39.904000\",\"lon\":\"116.391000\",\"update\":{\"loc\":\"2017-03-21 08:51\",\"utc\":\"2017-03-21 00:51\"}},\"now\":{\"cond\":{\"code\":\"101\",\"txt\":\"多云\"},\"fl\":\"0\",\"hum\":\"73\",\"pcpn\":\"0\",\"pres\":\"1027\",\"tmp\":\"6\",\"vis\":\"7\",\"wind\":{\"deg\":\"350\",\"dir\":\"东北风\",\"sc\":\"4-5\",\"spd\":\"18\"}},\"status\":\"ok\"}]}")
{
    "HeWeather5": [
        {
            "basic": {
                "city": "北京",
                "cnty": "中国",
                "id": "CN101010100",
                "lat": "39.904000",
                "lon": "116.391000",
                "update": {
                    "loc": "2017-03-21 08:51",
                    "utc": "2017-03-21 00:51"
                }
            },
            "now": {
                "cond": {
                    "code": "101",
                    "txt": "多云"
                },
                "fl": "0",
                "hum": "73",
                "pcpn": "0",
                "pres": "1027",
                "tmp": "6",
                "vis": "7",
                "wind": {
                    "deg": "350",
                    "dir": "东北风",
                    "sc": "4-5",
                    "spd": "18"
                }
            },
            "status": "ok"
        }
    ]
}
; No value

jsown:pretty-json, pretty JSON

Make JSON much more readable by add some newline or indent.

(jsown:pretty-json "{\"HeWeather5\":[{\"basic\":{\"city\":\"北京\",\"cnty\":\"中国\",\"id\":\"CN101010100\",\"lat\":\"39.904000\",\"lon\":\"116.391000\",\"update\":{\"loc\":\"2017-03-21 08:51\",\"utc\":\"2017-03-21 00:51\"}},\"now\":{\"cond\":{\"code\":\"101\",\"txt\":\"多云\"},\"fl\":\"0\",\"hum\":\"73\",\"pcpn\":\"0\",\"pres\":\"1027\",\"tmp\":\"6\",\"vis\":\"7\",\"wind\":{\"deg\":\"350\",\"dir\":\"东北风\",\"sc\":\"4-5\",\"spd\":\"18\"}},\"status\":\"ok\"}]}")
"{
    \"HeWeather5\": [
        {
            \"basic\": {
                \"city\": \"北京\",
                \"cnty\": \"中国\",
                \"id\": \"CN101010100\",
                \"lat\": \"39.904000\",
                \"lon\": \"116.391000\",
                \"update\": {
                    \"loc\": \"2017-03-21 08:51\",
                    \"utc\": \"2017-03-21 00:51\"
                }
            },
            \"now\": {
                \"cond\": {
                    \"code\": \"101\",
                    \"txt\": \"多云\"
                },
                \"fl\": \"0\",
                \"hum\": \"73\",
                \"pcpn\": \"0\",
                \"pres\": \"1027\",
                \"tmp\": \"6\",
                \"vis\": \"7\",
                \"wind\": {
                    \"deg\": \"350\",
                    \"dir\": \"东北风\",
                    \"sc\": \"4-5\",
                    \"spd\": \"18\"
                }
            },
            \"status\": \"ok\"
        }
    ]
}"

accessor utils

jsown:json-val, get value from JSON with key

(jsown:json-val (jsown:parse "{\"key1\":\"value1\",\"key2\":2}") "key1")

=>

"value1"

jsown:json-vals, get value from JSON object with keys(JavaScript style)

(jsown:json-vals (jsown:parse "{\"key1\":{\"key1.1\":\"value1.1\"},\"key2\":2}") 
                     "key1" "key1.1")

=>

"value1.1"

jsown:json-update-in, update value of JSON object with keys(JavaScript style)

(defvar *json* (jsown:parse "{\"key1\":{\"key1.1\":\"value1.1\"},\"key2\":2}"))
(jsown:json-update-in *json* ("key1" "key1.1") "new-value1.1")

=>

"new-value1.1"
*json*

=>

(:OBJ ("key1" :OBJ ("key1.1" . "new-value1.1")) ("key2" . 2))


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 jsown-utils

Utilities for Common Lisp JSON library jsown

Author

Muyinliu Xing <muyinliu@gmail.com>

License

MIT

Version

0.0.1

Dependencies
  • jsown (system).
  • closer-mop (system).
Source

jsown-utils.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 jsown-utils/src

Source

jsown-utils.asd.

Parent Component

jsown-utils (system).

Child Component

jsown-utils.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


4.1.1 jsown-utils/jsown-utils.asd

Source

jsown-utils.asd.

Parent Component

jsown-utils (system).

ASDF Systems

jsown-utils.


4.1.2 jsown-utils/src/jsown-utils.lisp

Source

jsown-utils.asd.

Parent Component

src (module).


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables