[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr bb85106ee9 27/84: doc: Add spec for nested table
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr bb85106ee9 27/84: doc: Add spec for nested tables and arrays of tables |
Date: |
Tue, 3 May 2022 09:58:09 -0400 (EDT) |
branch: externals/tomelr
commit bb85106ee98c1ee04100db9d298510b3f57e0751
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
doc: Add spec for nested tables and arrays of tables
---
README.org | 148 +++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 104 insertions(+), 44 deletions(-)
diff --git a/README.org b/README.org
index 607ad24589..ba51f2e6b2 100644
--- a/README.org
+++ b/README.org
@@ -30,7 +30,11 @@ specification defined below.
- [X] Arrays
- [X] Array of Arrays
- [ ] Tables
+ - [ ] Basic Tables
+ - [ ] Nested Tables
- [ ] Array of Tables
+ - [ ] Basic Array of Tables
+ - [ ] Nested Array of Tables
- [ ] Property Lists
* Specification and Conversion Examples
[[https://scripter.co/defining-tomelr/][Companion blog post]]
@@ -389,14 +393,15 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
}
#+end_example
** TOML Tables: Maps or Dictionaries or Hash Tables
-*** S-expression
+*** Basic TOML Tables
+**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref tables
'((table-1 . ((key1 . "some string")
(key2 . 123)))
(table-2 . ((key1 . "another string")
(key2 . 456))))
#+end_src
-*** TOML
+**** TOML
#+begin_src toml
[table-1]
key1 = "some string"
@@ -406,7 +411,7 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
key1 = "another string"
key2 = 456
#+end_src
-*** JSON Reference
+**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
(json-encode-pretty
<<tables>>)
@@ -425,8 +430,48 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
}
}
#+end_example
+*** Nested TOML Tables
+**** S-expression
+#+begin_src emacs-lisp :eval no :noweb-ref nested-tables
+'((table-1 . ((table-1a . ((key1 . "some string")
+ (key2 . 123)))
+ (table-1b . ((key1 . "foo")
+ (key2 . 98765))))))
+#+end_src
+**** TOML
+#+begin_src toml
+[table-1]
+ [table-1.table-1a]
+ key1 = "some string"
+ key2 = 123
+ [table-1.table-1b]
+ key1 = "foo"
+ key2 = 98765
+#+end_src
+**** JSON Reference
+#+begin_src emacs-lisp :noweb yes :exports results
+(json-encode-pretty
+ <<nested-tables>>)
+#+end_src
+
+#+RESULTS:
+#+begin_example
+{
+ "table-1": {
+ "table-1a": {
+ "key1": "some string",
+ "key2": 123
+ },
+ "table-1b": {
+ "key1": "foo",
+ "key2": 98765
+ }
+ }
+}
+#+end_example
** TOML Array of Tables: Lists of Maps
-*** S-expression
+*** Basic Array of Tables
+**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref table-arrays
'((products . (((name . "Hammer")
(sku . 738594937))
@@ -434,16 +479,6 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
((name . "Nail")
(sku . 284758393)
(color . "gray"))))
-
- (fruits . (((name . "apple")
- (physical . ((color . "red")
- (shape . "round")))
- (varieties . ((((name . "red delicious"))
- ((name . "granny smith"))))))
- ((name . "banana")
- (varieties . (((name . "plantain")))))))
-
-
(org_logbook . (((timestamp . 2022-04-08T14:53:00-04:00)
(note . "This note addition prompt shows up on typing the
`C-c C-z` binding.\nSee
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."))
((timestamp . 2018-09-06T11:45:00-04:00)
@@ -451,7 +486,7 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
((timestamp . 2018-09-06T11:37:00-04:00)
(note . "A note `mono`.")))))
#+end_src
-*** TOML
+**** TOML
#+begin_src toml
[[products]]
name = "Hammer"
@@ -462,20 +497,6 @@ nested_mixed_array = [ [ 1, 2 ], [ "a", "b", "c" ] ]
sku = 284758393
color = "gray"
-[[fruits]]
- name = "apple"
- [fruits.physical] # subtable
- color = "red"
- shape = "round"
- [[fruits.varieties]] # nested array of tables
- name = "red delicious"
- [[fruits.varieties]]
- name = "granny smith"
-[[fruits]]
- name = "banana"
- [[fruits.varieties]]
- name = "plantain"
-
[[org_logbook]]
timestamp = 2022-04-08T14:53:00-04:00
note = """This note addition prompt shows up on typing the `C-c C-z` binding.
@@ -487,7 +508,7 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
timestamp = 2018-09-06T11:37:00-04:00
note = """A note `mono`."""
#+end_src
-*** JSON Reference
+**** JSON Reference
#+begin_src emacs-lisp :noweb yes :exports results
(json-encode-pretty
<<table-arrays>>)
@@ -508,6 +529,58 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
"color": "gray"
}
],
+ "org_logbook": [
+ {
+ "timestamp": "2022-04-08T14:53:00-04:00",
+ "note": "This note addition prompt shows up on typing the `C-c C-z`
binding.\nSee
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."
+ },
+ {
+ "timestamp": "2018-09-06T11:45:00-04:00",
+ "note": "Another note **bold** _italics_."
+ },
+ {
+ "timestamp": "2018-09-06T11:37:00-04:00",
+ "note": "A note `mono`."
+ }
+ ]
+}
+#+end_example
+*** Nested Array of Tables
+**** S-expression
+#+begin_src emacs-lisp :eval no :noweb-ref nested-table-arrays
+'((fruits . (((name . "apple")
+ (physical . ((color . "red")
+ (shape . "round")))
+ (varieties . ((((name . "red delicious"))
+ ((name . "granny smith"))))))
+ ((name . "banana")
+ (varieties . (((name . "plantain"))))))))
+#+end_src
+**** TOML
+#+begin_src toml
+[[fruits]]
+ name = "apple"
+ [fruits.physical] # subtable
+ color = "red"
+ shape = "round"
+ [[fruits.varieties]] # nested array of tables
+ name = "red delicious"
+ [[fruits.varieties]]
+ name = "granny smith"
+[[fruits]]
+ name = "banana"
+ [[fruits.varieties]]
+ name = "plantain"
+#+end_src
+**** JSON Reference
+#+begin_src emacs-lisp :noweb yes :exports results
+(json-encode-pretty
+ <<nested-table-arrays>>)
+#+end_src
+
+#+RESULTS:
+#+begin_example
+{
"fruits": [
{
"name": "apple",
@@ -534,23 +607,10 @@ See
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#D
}
]
}
- ],
- "org_logbook": [
- {
- "timestamp": "2022-04-08T14:53:00-04:00",
- "note": "This note addition prompt shows up on typing the `C-c C-z`
binding.\nSee
[org#Drawers](https://www.gnu.org/software/emacs/manual/html_mono/org.html#Drawers)."
- },
- {
- "timestamp": "2018-09-06T11:45:00-04:00",
- "note": "Another note **bold** _italics_."
- },
- {
- "timestamp": "2018-09-06T11:37:00-04:00",
- "note": "A note `mono`."
- }
]
}
#+end_example
+
** Combinations of all of the above
*** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref medley
- [elpa] externals/tomelr 05d2cafcd9 09/84: test: Add test for boolean scalar key-value pairs, (continued)
- [elpa] externals/tomelr 05d2cafcd9 09/84: test: Add test for boolean scalar key-value pairs, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 2ea3b5e032 03/84: fix!: Set boolean false using :false value, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 28642f2e78 05/84: fix: dates will be strings in Lisp, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 52dc93201d 08/84: feat: First cut -- Port json-encode from json.el to tomelr-encode, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 7cd15e79b8 10/84: tool(ci): Add GHA setup, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c872e9efc1 17/84: test: Add test for integer scalar key-value pairs, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a1f434f03a 31/84: feat: Support nested TOML tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 6bbe740e52 28/84: test: Test that 'false is also considered as boolean false in TOML, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 9c91e0dc07 18/84: test: Add test for float scalar key-value pairs, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 96c890a68b 23/84: feat: Convert Lisp lists to TOML arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr bb85106ee9 27/84: doc: Add spec for nested tables and arrays of tables,
ELPA Syncer <=
- [elpa] externals/tomelr 1d65064ffa 20/84: feat: Recognize local date format YYYY-MM-DD, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 2810504e84 32/84: feat: Add basic support for S-exp plists -> TOML conversion, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 0f4e7b4f2c 47/84: fix: Better detection of nested TTA, but still wip, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr cff1f8aa89 38/84: fix: Support TOML tables arrays specified as plist vector, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4c419bcee2 37/84: fix: Support TOML tables specified as plists, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr baf81228bc 45/84: fix: Correct the spec for nested array of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4dda8e6be3 46/84: chore: Style edits in a test, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 5959b90ffa 44/84: fix: Don't let TOML tables be recognized as TOML tables arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables correctly, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4386d99a85 65/84: refactor(minor): Use `tomelr--toml-table-p`, ELPA Syncer, 2022/05/03