Skip to content

Commit

Permalink
Merge pull request #736 from jsk-ros-pkg/PR/update_json_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Jan 25, 2023
2 parents 717228d + 4314d32 commit e17f10f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions roseus_mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,25 @@ roseus_mongo
## How to use

see [euslisp/mongo-client-sample.l](euslisp/mongo-client-sample.l)

### roseus json example

Parse from json string
```
> load "package://roseus_mongo/euslisp/json/json-decode.l"
> setq *parsed* (json::parse-from-string "{\"key1\" : \"value1\", \"key2\" : \"value2\"}") ;; parse json-string
> assoc :key1 *parsed*
(:key1 . "value1")
> car (assoc :key1 *parsed*)
:key1
> cdr (assoc :key1 *parsed*)
"value1"
```

Convert lisp-alist to json string
```
> load "package://roseus_mongo/euslisp/json/json-encode.l"
> setq *alist* '(("key1" . "value1") ("key2" . "value2"))
> json::stream->string #'json::encode-alist *alist*
"{\"key1\":\"value1\",\"key2\":\"value2\"}"
```

0 comments on commit e17f10f

Please sign in to comment.