if(Value == "{}") Broken? (solved)

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
User avatar
Tanthos
Giant
Posts: 176
Joined: Thu Mar 28, 2013 6:55 pm
Location: United States

if(Value == "{}") Broken? (solved)

Post by Tanthos »

I think that the ability to check whether a json object is empty via simply comparing string value "{}" has been broken in the most recent version of maptool. I used to use it extensively before b91, but now it always causes an error. I'm thinking that the parser is taking the empty json as a literal empty json rather than allowing it to be considered a string.

Anyone else can confirm?

UPDATE: I also get an error if I check to see if a json object == 0. Apparently the IF statement does not like to compare json objects to any other variable type.
Last edited by Tanthos on Sat Feb 21, 2015 8:51 pm, edited 1 time in total.

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

Re: if(Value == "{}") Broken?

Post by aliasmask »

I don't think you can compare a json to a json that way. It may have worked before as a string comparison, but "{}" isn't really a string, but a json object. I recommend just using json.isEmpty(Value) instead because it works for strings and jsons. You can also use Wiki: json.equals().


Post Reply

Return to “Macros”