So I've read all the posts and followed along at home. I'm not a CS major. I have an array:
{% set testArray = {
name: "John Doe",
email: "[email protected]",
players: [
{
playerName: "Jane Doe",
PID: 8885551212,
TID: 1234,
},
{
playerName: "Billy Doe",
PID: 8285551,
TID: 1222,
},
],
follows : [
'234',
'345',
'999',
]}%}
Great, it verks!! When I ask it to spit it out via: {{testArray|json_encode}}, it spits out:
{"name":"John Doe","email":"[email protected]","players":[{"playerName":"Jane Doe","PID":8885551212,"TID":1234},{"playerName":"Billy Doe","PID":8285551,"TID":1222}],"follows":["234","345","999"]}
Huzzah, go me!
Now, if I want to update the players
array, I'm trying this
{% set testA = { playerName:"Henry Doe",PID: 8885551333,TID: 1} %}
{% set testArray = testArray|merge({ "players": [testA]} ) %}
It'a good boi and does this BUT it overwrites the other 2 objects in the array and outputs
{"name":"John Doe","email":"[email protected]","players":[{"playerName":"Henry Doe","PID":8885551333,"TID":1}],"follows":["234","345","999"]}
So, the question is A) is it even possible? b) WTAF am I doing wrong?