[Object Object] at parsing JSON

Hello, im making a script that uses JSON.encode…
Im am trying to parse it into javascript, it kinda works but im getting a [Object Object] at the next:
{"data":{"amount":2","label":"amount is 2"},"item":"sandwich"}

Javascript Snippet:

var txt = DrugsData.info;
var obj = JSON.parse(txt);
currentDrugsItem = obj.item;
currentDrugsData = obj.data;

currentDrugsItem is returning “sandwich” so as said in the stringify, but currentDrugsData is returning [Object Object]…

Someone has any idea how to fix this issue in javascript/jquery?

data is another array, so for example you want the amount you do obj.data.amount

Ye, but since im using different stringify for every item, cuz some items need data that other item doenst have, and then its gonna be an issue to parse it, right?

And besides that, i later need to have it in 1 string in the lua code, so i need it to be 1 string, and not multiple like obj.data.amount, obj.data.label

Well then you need to encode your data different

Like what?

It’s your data, you know what you want to pass to your javascript. If you only want the label then just encode it like

local data = {
    item = "sandwich",
    label = "amount is 2"
}

json.encode(data)
[...]

Or just get obj.data.label in your javascript, the question is kinda confusing you are asking me how to encode your data while you know what you want to receive

I will give it a try, thnx for helping :upside_down_face: