简体   繁体   中英

Append inside Array inside Object - Watson Assistant

I've created this Array:

{"intent":[],"canonica":[],"entities":[{"name":[],"value":[]}]}

Now I have to append an value inside entities.value but append can't work in this case.

Any suggestions?

Thanks!

From the snippet it seems you have created an object not an array. If so then do

data.entities[0].value.push(1); where data.entities will first get the entities array from the data object

 let data = { "intent": [], "canonica": [], "entities": [{ "name": [], "value": [] }] } data.entities[0].value.push(1); console.log(data) 

做到这一点应entitles[0].value.push()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM