Sanford Whiteman

Code Anatomy: Get a real array from an array-like string (a.k.a. “list”)

Blog Post created by Sanford Whiteman on Oct 26, 2016

JavaScript arrays are magic. Really, they are.  Array#map… Array#find… Array#some… don't know how I could get anything done without them.


Problem is, in the CRM and MA world, array-like data — that is, a set of independent values — rarely comes to you as a real array. Instead, you get fields that humans might think of as a “list,” but which really is just a single big string. Take this Marketo field at one of my clients:




You look at that as a developer and groan. Even though you know what it's supposed to represent (at least right now) and end users may not see the inherent problems, you see the potential trouble to come. You note the uneven spacing around the commas; wonder what happens if a single value needs to contain a comma; dread searching accurately for "Monthly-Diamond" when another subscription might be "Bi-Monthly-Diamond" and values can occur in any order.

Read the full post on TEKNKL :: Blog →