asafh / jtoml Goto Github PK
View Code? Open in Web Editor NEWTOML Parser for Java
License: Other
TOML Parser for Java
License: Other
KeyGroup fix and add:
public <T extends Enum> getAsEnum(String key, Class<T> clz) {
return Enum.valueOf(clz,getString(key));
}
ObjectDeserializer in createField, check if type is enum call getAsEnum else same logic.
Is it possible to traverse a TOML structure that is not known a priori?
E.g. I have a file whose structure looks likes this:
["unknown-string-1"]
channel_id = "foo"
keywords = ["foo, foo"]
["unknown-string-2"]
channel_id = "bar"
keywords = ["bar, bar"]
I don't know the table names. Is it possible to iterate over the tables and access their names?
It would be fantastic if jtoml would be available in maven central soon. At the moment no (competing) TOML library is available in maven central, so this would be a great opportunity to become the de-facto Java toml library :)
The following file
name = 'bob'
Fails with this exception
Exception in thread "main" io.ous.jtoml.ParseException: Could not identify value 'bob'
at io.ous.jtoml.impl.ConsumableType.readValue(ConsumableType.java:38)
at io.ous.jtoml.impl.Parser.onAssignment(Parser.java:96)
at io.ous.jtoml.impl.Parser.onLine(Parser.java:61)
at io.ous.jtoml.impl.Parser.parse(Parser.java:43)
at io.ous.jtoml.JToml.parse(JToml.java:33)
at io.ous.jtoml.JToml.parse(JToml.java:21)
at io.ous.jtoml.JToml.parse(JToml.java:18)
at org.thelq.pircbotx.TomlTest.main(TomlTest.java:19)
JToml.parseString will actually not throw an IOException. It seems to make sense to remove "throws IOException" from the method. It won't make any binary break, but requires source code changes when recompiling the clients.
Attempting to parse the following file
[[servers]]
name = "server1"
[[servers]]
name = "server2"
Throws this during parsing
Exception in thread "main" io.ous.jtoml.ParseException: Cannot overwrite key [servers]
at io.ous.jtoml.impl.Parser.onKeygroup(Parser.java:118)
at io.ous.jtoml.impl.Parser.onLine(Parser.java:58)
at io.ous.jtoml.impl.Parser.parse(Parser.java:43)
at io.ous.jtoml.JToml.parse(JToml.java:33)
at io.ous.jtoml.JToml.parse(JToml.java:21)
at io.ous.jtoml.JToml.parse(JToml.java:18)
at org.thelq.pircbotx.TomlTest.main(TomlTest.java:19)
This is valid TOML according to the toml standard readme: https://github.com/toml-lang/toml
println JToml.parseString('dob=1979-05-27T07:32:00-08:00').getDate('dob')
Caught: io.ous.jtoml.ParseException: Extra characters at -05-27T07:32:00-08:00
io.ous.jtoml.ParseException: Extra characters at -05-27T07:32:00-08:00
at io.ous.jtoml.impl.Parser.onAssignment(Parser.java:99)
at io.ous.jtoml.impl.Parser.onLine(Parser.java:61)
at io.ous.jtoml.impl.Parser.parse(Parser.java:43)
at io.ous.jtoml.JToml.parse(JToml.java:33)
at io.ous.jtoml.JToml.parseString(JToml.java:26)
at io.ous.jtoml.JToml$parseString.call(Unknown Source)
at jtoml2.run(app.groovy:18)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.