Link to home
Start Free TrialLog in
Avatar of Anthony Lucia
Anthony Lucia

asked on

JSONPATH

I have the following JSON structure:

{ "identification" : "AlphaBeta" }

Open in new window


What I want to do is write a conditional that states something like (In Pseudo code)

  IF identification = 'Alpha*'
     TRUE
  ELSE 
     FALSE

Open in new window


Therefore the function above would return true if
'identification' was equal to any of the three values below

AlphaGraphics
AlphaCentauri
AlphaBeta

Open in new window


But would return false if 'identification' is equal to the following value:

AlaskaBeta

Open in new window


How do I convert the pseudo code above to JSONPATH ?

What would that look like in JSONPATH ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
test page : http://jsfiddle.net/SEjH2/

function checkIdent(j) {
    return j.identification.indexOf("Alpha") == 0;
}

// TRUE
var j = { "identification" : "AlphaBeta" };
alert( checkIdent(j) );

//  FALSE
var k = { "identification"  : "AlaskaBeta" };
alert( checkIdent(k) );

Open in new window