Comments (8)
if I'm given guidance on what the examples should look like, I'm more than willing to submit an update.
from libucl.
That works fine with Lua.
local u = require "ucl"
local p = u.parser()
p:parse_file('tt.ucl')
print(u.to_json(p:get_object()))
gives:
{
"section": {
"number": 10000,
"subsection": {
"host": [
{
"host": "hostname",
"port": 900
},
{
"host": "hostname",
"port": 901
}
]
},
"flag": true,
"param1": "value1",
"time": 0.200000,
"string": "something",
"param": "value"
},
"param": "value"
}
Unfortunately, I don't know the details about how Python part works as it has been contributed by another person.
from libucl.
I'll take a look at the python. But will you be updating the JSON in the example to match the above? I only even tried this because of the mismatch.
from libucl.
Ok, looks like lua is treating objects as arrays in special, undocumented cases (at least I couldn't find anything about checking obj->next in libucl/doc):
https://github.com/vstakhov/libucl/blob/master/lua/lua_ucl.c#L156
Which is why it works, and it doesn't work on the Python code:
https://github.com/vstakhov/libucl/blob/master/python/src/uclmodule.c#L46
from libucl.
Yes, multi-value keys were the biggest design mistake in UCL, I agree :(
from libucl.
why not simply change libucl to return the object as an array when that happens? at least it'd give expected results in that consumers should be treating them as arrays instead of objects.
It'd also catch cases where consumers weren't expecting an object become array, and also handle the POLA case where the consumer wasn't handling it (e.g. this python library), and the other objects just disappear, or ignored causing the end user no idea WHY their configuration isn't working the way they expected it to.
from libucl.
why not simply change libucl to return the object as an array when that happens?
libucl has a parser flag to do that: UCL_PARSER_NO_IMPLICIT_ARRAYS
from libucl.
Ok, adding the flag fixes UCL_PARSER_NO_IMPLICIT_ARRAYS the python test case. I'll submit a PR for Python module including a test for this case.
from libucl.
Related Issues (20)
- Why is the inner "default" block needed here?
- Feature: implicit booleans
- Completion of error handling
- Formal UCL grammar definition HOT 5
- Assert failure in ucl_msgpack_insert_object (ucl_msgpack.c:845) HOT 2
- Schema tests failed with latest master HOT 1
- Does registering variables from Python work and how can I use it?
- License of python bindings / Missing license file for python bindings HOT 1
- vcpkg port? HOT 2
- Memory safety bug in hashtable replace HOT 7
- [DISCUSSION]: Using dot-notation for setting values HOT 1
- Release a new pip package HOT 2
- Heap-buffer-overflow in ucl_maybe_parse_number /src/libucl/src/ucl_parser.c HOT 1
- Cannot convert example from YAML to UCL using ucl_tool HOT 3
- Heap-buffer-overflow in ucl_skip_comments function of ucl_parser.c:182:11
- compile error due to undefined PRId64
- python/setup.py: incremental build fails due to already existing setup.py link
- Feature request: A parser flag to expand variables inside marco options. HOT 1
- How to load libucl through cmake
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 libucl.