I know how to read a JSON array; the problem I'm having is that JSON.Append isn't appending correctly, whether the JSON array is empty or not. I changed my token property have a default value of :
and this is what the same property looks like after the macro runs a couple of JSON.appends:
Code: Select all
[{"ActionTaken":"Blocking"},[{"ActionTaken":"Martial Artist"},[{"ActionTaken":"default"}]]]
Each new object added is getting the surrounding '[]' characters, as opposed to simply enclosing the whole array with a single pair of them. I'm using an older version, 1.10.4, but it's not that old. Any idea what's going on here? In the same campaign file, I have another simple macro using json.append in an identical manner which works perfectly:
Code: Select all
[h: gadget = json.set("", "Gadget",sName, "Desc",sDesc,
"AV",iAV,"EV",iEV,"Rel",iRN,"Ammo",iAmmo,"Body",iBody,"Linked",sLink, "Melee",iMelee)]
[h: Gadgets = json.append(gadget, Gadgets)]
Here's an example Gadgets property value copied from one of the tokens in the file after getting updated:
Code: Select all
[{"Gadget":"White Sound Gen.","Desc":"Sonic Beam","AV":0,"EV":10,"Rel":4,"Ammo":0,"Body":6,"Linked":"DEX","Melee":0},{"Gadget":"Grappling Hook + Winch","Desc":"5 APs long","AV":0,"EV":9,"Rel":0,"Ammo":0,"Body":6,"Linked":"DEX","Melee":0},{"Gadget":"Laser Attachment","Desc":"Heat Vision","AV":0,"EV":7,"Rel":3,"Ammo":0,"Body":6,"Linked":"DEX","Melee":0}]
This is absolutely perfect! The only difference i can see between the two pieces of code is that the Phase Info code is a called function whereas the Gadget code is not. Any idea what's going on here?