lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If you pass in the json.decode.simple config table to decode, you will
get actual nils for null and undefined.

json.decode("null", json.decode.simple)
json.decode.getDecoder(json.decode.simple)("null")

On 9/11/10, Alexander Gladysh <agladysh@gmail.com> wrote:
> Hi, list!
>
> I wrote a small tool to convert JSON data to Lua (using luajson:
> http://github.com/harningt/luajson):
>
> http://github.com/agladysh/json2lua/blob/master/json2lua
>
> However, there is a problem with nulls inside JSON data. The
> json.decode() inserts json.util.null() there, but, to get serializable
> output, I need Lua nils.
>
> I don't want to recursively traverse loaded data and replace nulls with
> nils.
>
> Is luajson author here? Can something be done? I suggest adding
> optional flag to json.decode().
>
> Thanks,
> Alexander.
>
> P.S. Lua / JSON module autors! Submit your modules to LuaRocks! Now we
> have only two JSON modules in repository, but a zillion others lying
> around.
>
>


-- 
Thomas Harning Jr.