GithubHelp home page GithubHelp logo

empty arrays not handled correctly about json.lua HOT 2 CLOSED

rxi avatar rxi commented on August 22, 2024
empty arrays not handled correctly

from json.lua.

Comments (2)

rxi avatar rxi commented on August 22, 2024

This works as expected for me, with corrections to your example:

local json = loadfile("json.lua")()
local d = json.decode('{"tags":[]}')
print( string.format("[test] %s len:%d", tostring(d.tags), #d.tags) )

I get the output:

[test] table: 0x99a76e0 len:0

Empty arrays are also a test case in the test.lua file: https://github.com/rxi/json.lua/blob/master/test/test.lua#L170

from json.lua.

ssmogos avatar ssmogos commented on August 22, 2024

got this error before (still had my console with it) - as d was nil:

lua: test.lua:3: attempt to index local 'd' (a nil value)
stack traceback:
test.lua:3: in main chunk
[C]: in ?

but just downloaded your latest json.lua file and works just fine. Maybe my prev file was corrupted... Unfortunately I just overwrote it and do not have the prev file that I used in the test.

But it works just fine now. Sorry for you spending the time on this non-issue and thanks for this great lib!

from json.lua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.