0
local json = require ("dkjson")
local obj = {"dogs":[{"photo":"http://example.com/1.jpg","price":20}]}
obj_t = json.decode(obj)

I'm use construction: obj_t.dogs.photo and this return nil

1 Answer 1

1

This is not a valid Lua code, but if we fix the string (local obj = [==[{"dogs":[{"photo":"http://example.com/1.jpg","price":20}]}]==]) then it looks like the problem is that you have a map with an array that has a map in it, so you're missing accessing the array element. You need to use something like obj_t.dogs[1].photo.

Sign up to request clarification or add additional context in comments.

1 Comment

I get this object from response api

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.