hjson-d 0.1.0
HJSON parser compatible with std.json.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
hjson-d
Hjson-d is a HJSON parser written in D. HJSON is a syntax extension to JSON which improves readability and helps avoid bugs caused by missing/trailing commas:
// example.hjson
{
"name": "HJSON",
"readable": {
omitQuotes: This is a quoteless string
omitCommas: [
1
2
3
]
trailingCommas: {
a : true,
b : false,
c : null,
}
multilineStrings:
'''
Lorem
ipsum
'''
# Comments
// C-style comments
/*
Block
comments
*/
}
}
Usage
You can parse HJSON into a std.json.JSONValue
by importing hjson
and using parseHJSON
:
import std.file : readText;
import hjson;
JSONValue value = readText("example.hjson").parseHJSON;
When parseHJSON
encounters invalid HJSON it will throw a HJSONException
.
Limitations
- Emitting HJSON is not supported
parseHJSON
only reads a single HJSON value and will not attempt to look further in the input to find errors. Because of that certain errors will not be detected:
[1, 2, 3, 4] 5 #Trailing 5 will not cause an error because parsing stops after [1, 2, 3, 4]
- Parsing from arbitrary forward ranges is currently not supported, but is planned for the future.
- Registered by Krzysztof Jajeśnica
- 0.1.0 released 4 years ago
- k2aj/hjson-d
- MIT
- Copyright © 2020, Krzysztof Jajeśnica
- Authors:
- Dependencies:
- none
- Versions:
-
0.2.0 2020-Sep-14 0.1.0 2020-Sep-12 ~master 2020-Sep-14 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
9 downloads total
-
- Score:
- 0.3
- Short URL:
- hjson-d.dub.pm