changeset 61:e3abe28c5a3a draft

Explain JSON parser better and add example files
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 24 May 2019 01:13:35 +0200
parents be810f4c68c0
children f2515a9dc9ef
files README.md test.json test2.json
diffstat 3 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Fri May 24 01:11:33 2019 +0200
+++ b/README.md	Fri May 24 01:13:35 2019 +0200
@@ -5,6 +5,10 @@
 
 There are examples in the form of
 * a JSON parser in `pcombinators/json_test.py` and
+ * test it with `parse_json('{"ob": "ject"}')` or `Value().parse(ParseFileState('test.json'))`.
+ * It does not accept whitespace except in strings. `parse_json()` takes care
+ of this in a simple way, but keep this in mind when trying to parse your own
+ input.
 * a parser for arithmetic expressions in `pcombinators/arith_test.py`.
 
 More simple examples:
@@ -44,7 +48,8 @@
 # >> (['HELLO', 'WORLD', 4.4], ParseState(hello world 2.2<>))
 ```
 
-NOTE: pcombinators is super slow right now... it could likely benefit from tightening parsers and
+NOTE: pcombinators is quite slow right now, especially if you don't take care
+of performance yourself... it could likely benefit from tightening parsers and
 making fewer calls to sub-parsers. Production use isn't quite recommended :)
 
 ## Performance tips
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test.json	Fri May 24 01:13:35 2019 +0200
@@ -0,0 +1,1 @@
+{"id":1,"name":"Foo","price":123,"tags":["Bar","Eek"],"stock":{"warehouse":300,"retail":20}}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test2.json	Fri May 24 01:13:35 2019 +0200
@@ -0,0 +1,1 @@
+{"a":44}