Comments (3)
Thanks for the input but this sounds like a problem of JSON, not Hjson. If JSON loses the type information we can hardly get it back by guessing it in Hjson.
I see that this would be a nice workaround for your issue but it has too many drawbacks to implement it here.
If you simply want a workaround you could just walk your object tree yourself and reuse DSF from Hjson to parse any string values:
// init
var runDsf = dsf.loadDsf(dsfDef, "parse");
// parse:
var dsfValue = runDsf(value);
from hjson-js.
Thanks for looking this up.
I don't think that's a problem with JSON. JSON was designed as a portable and minimalist data-interchange format, i.e. to be simple and have few types. But this does not mean it cannot be augmented with type information, while still keeping JSON syntax. Providing both the decoder and the encoder agree on some way to decode/encode type information, it is possible. An example of a high profile project that does exactly this is transit-format.
The outcome is that Hjson could be serialized to and parsed from JSON without losing DSL type information. This would allow Hjson to use DSL in a similar way YAML uses tags.
If this still does not convince you, you can close this issue, I understand if you think this might not fit in Hjson. 😃
from hjson-js.
I'm sorry but this not the purpose of Hjson. You are welcome to fork or reuse the DSF parts though.
from hjson-js.
Related Issues (20)
- Roundtrip doesn't preserve blank lines HOT 1
- Option to throw error when parse encounters duplicate keys?
- move cli to hjson-cli?
- Schema autocomplete support HOT 1
- hjson.stringify() ignores 'toJSON()' methods HOT 3
- Issue with parsing default tsconfig.json file during page testing HOT 3
- hjson-comments.extract/merge doesn't roundtrip array comments correctly. HOT 4
- Proposal: Add option "serializeAlphabetically"
- Add GitHub releases
- Stringify method works incorrectly
- How does this compare to json5? HOT 3
- Bad string containing newline at line 4,230 HOT 1
- The require-config features demands .hjson extension
- Human friendly comments
- dsf.math cannot handle "nan" without newline following HOT 2
- Parse removes newline for comment if it last entry in entity
- When written with `keepWsc: true,` carries comments
- emitRootBraces was removed?
- when converting objects (stringify, parse) incorrectly handles fields with undefined
- Usage in browsers?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hjson-js.