json.removeAll application

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
TeeJot
Kobold
Posts: 1
Joined: Thu Oct 15, 2020 8:22 am

json.removeAll application

Post by TeeJot »

Hi there,
can someone explain the json.removeAll command to me and give an example?
I'm looking for a way to clear the content of an array. Either I do that with:
[h: test.arr = '[]']
or with (short from my memory without exam):
[h, while((json.length (test.arr) > 0), code:
{[h: test.arr = json.remove(test.arr, 0)]}

Thanks for the support!
TeeJot

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: json.removeAll application

Post by aliasmask »

Never had to use this but I assume something like this

Code: Select all

[H: obj = json.set("{}","name","Monster Name","size",2,"color","blue")]
<!-- remove color -->
[H: obj = json.removeAll(obj,json.set("{}","color",""))]
Looks like the same functionality as json.difference(). In your example, I would just stick with json.remove.

Post Reply

Return to “Macros”