A subset of S-expressions as a lightweight data-interchange format.
S-expressions is an elegant markup: simple, unambiguius, and easy to parse.
(value
(#t #f
string number
(object
(#hash()
#hash(pairs)))
(array
(()
(values))))
(pair
(string . value))
(pairs
(pair
(pair values)))
(values
(value
(value values)))
Unlike JSON, a value cannot be null.
Example:
Suppose we have a strip containing the following s-expression:
#hash(("name" . "Introduction to Ceylon")
("authors" . ("Stef Epardaud" "Emmanuel Bernard")))
We can parse it as following:
String get_name(String sexp) {
Value parsed = parse(sexp);
assert (is SexpObject parsed);
return parsed.getString("name");
}
| Packages | |
| io.github.weakish.sexp | Currently only implemented decoding. |
| Dependencies | ||
ceylon.json | 1.3.2 | |
ceylon.test | 1.3.2 | |
Currently only implemented decoding. See TODO.md for planned features.
APIs are similar to ceylon.json.
| Aliases | |
Value | shared Value=> String|Boolean|Integer|Float|SexpObject|SexpArrayAn SEXP value, a |
| Annotations | |
licensedUnder | shared LicensedUnderAnnotation licensedUnder(String description)Like |
LicensedUnderAnnotation | shared final sealed LicensedUnderAnnotationClass for licensedUnder annotation. |
| Functions | |
parse | shared Value parse(String string)Parses an SEXP string into an SEXP value Throws
|
parseBool | shared Boolean parseBool(Tokenizer tokenizer)Parse #t, #T, #f, #F, consuming any initial whitespace. Throws
|
parseKeyOrString | shared String parseKeyOrString(Tokenizer tokenizer)Parse a String literal, consuming any initial whitespace |
parseNumber | shared Integer|Float parseNumber(Tokenizer tokenizer)Parse a number, consuming any initial whitespace. |
visit | shared void visit(Value subject, Visitor visitor, Boolean sortedKeys = false)Recursively visit the given subject using the given visitor. If
Parameters:
|
| Classes | |
Builder | shared Builder |
Parser | shared ParserA parser for SEXP data presented as a Tokenizer which calls the given visitor for each matched rule. To construct a JSON model the visitor would be a |
SexpArray | shared SexpArrayS-expression array. |
SexpObject | shared SexpObjectS-expression object (hashmap). |