[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: need help: some features of Lua don't fit well together
- From: Javier Guerra Giraldez <javier@...>
- Date: Tue, 14 Apr 2015 11:08:08 -0500
Hi Kostja!
On Tue, Apr 14, 2015 at 10:37 AM, Konstantin Osipov
<kostja.osipov@gmail.com> wrote:
> Since there is no easy way to distinguish between a Lua map and an
> array, we have to traverse each argument of conversion, and check that
> its keys are numeric. If all keys are numeric, keys start with 1,
> and there are no gaps in keys, it's a list. Otherwise, it's a map and
> it must be treated the same way as a scalar - become a list field.
in your data model, what is the definition of "map"? the full
featureset of Lua tables? if so, i think you would have to consider
arrays as a subset of maps.
if, OTOH, your maps have some more specific definition, you could take
advantage of it. for example, JSON objects allow only strings as keys
so simply testing (value[1] ~= nil) is enough to discriminate between
them
--
Javier