Validate JSON Hash Map Data

SanfordWhiteman
Level 10 - Community Moderator

Re: Validate JSON Has Map Data

Can only imagine you're spelling the property name wrong.

Adam
Level 2

Re: Validate JSON Has Map Data

If that was the case it wouldn't be printing the value on the page.

SanfordWhiteman
Level 10 - Community Moderator

Re: Validate JSON Has Map Data

A direct {{lead.token}} name isn't the same as the property name in VTL.

Adam
Level 2

Re: Validate JSON Has Map Data

I"m sorry I don't understand what you mean on this? I shared the code I have do you see what I have wrong?

SanfordWhiteman
Level 10 - Community Moderator

Re: Validate JSON Has Map Data

I'm saying that being able to output {{lead.Field Name}} directly in an email doesn't mean the field is accessible as $lead["Field Name"] in Velocity.

 

You should assume the token name and the Velocity property name are different (occasionally they're the same, but consider that a coincidence). You only know the Velocity name when you're in the Velocity editor.

Adam
Level 2

Re: Validate JSON Has Map Data

Am I not in the velocity editor with this?

 

Screen Shot 2020-06-08 at 9.32.13 PM.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Validate JSON Has Map Data

Yes, that's the Velocity Script Editor, of course.

 

But elsewhere, you've referred to {{lead.token}} syntax. That isn't Velocity, and the ability to output a {{lead.token}} in the body of an email doesn't predict anything about Velocity code and/or naming conventions.

 

In any case, the code provided to check the null-ness or empty-ness of a String property is time-tested and correct. As for what else is going wrong on your side... can't say without access to your instance.

Adam
Level 2

Re: Validate JSON Has Map Data

I don't understand what is going on, since switching from the SCRIPT token to store my hash, to storing it in a TEXT token (because we can no longer update SCRIPT with API) none of my IF statements that previously worked are functional (They always return FALSE), and I cannot find any way to get them working. Everything else is working as expected (Printing date, loops etc).

Because i can print data and retrive it as before I can't see my data structure being any different.

Also my Lead Tokens for direct values the IF statements work properly, but not checking values against my text token.

 

Where clinic's is the hash map, below is always FALSE( checking if it exists). So what is different about IF statements and Text Tokens?

#if($clinics.Map.get($item) .

 

Below is a lead field, it works:

#if ($leadData.Map.get($item).apptAllowed == 1)

Adam
Level 2

Re: Validate JSON Has Map Data

It feels like since the switch to a TEXT token, like marketo isn't full recognizing this as an OBJECT and that, as soon as I try to assign a key into a variable or do an IF statement, it doesn't save it.

SanfordWhiteman
Level 10 - Community Moderator

Re: Validate JSON Has Map Data

What is it recognizing it as, if not a LinkedHashMap?