Forum Discussion
Just a comment on the impact to productivity… I have between 40 and 70 fields to map, multiplied by an average of 4 changes to the mapper to include the 0. So any real time savings of no code, gets eaten up with this tedious manual task. I also worry about using [0] in this fashion, as I was taught that this is bad practice in xslt/xpath.
Hi @acesario
I think the getFirst() method could help your scenario.
I think the expression using getFirst() with your example would look something like this:
$.getFirst(‘Student’).getFirst(‘Student_Data’).getFirst(‘Student_Person_Data’).getFirst(‘Personal_Profile_Data’).Date_of_Birth
This relies on those fields always being present and arrays. If there are times that is not true additional logic will be needed.
Thank you for your response @cjhoward18.
However, my snap seems to be requiring jsonpath… if I do a getFirst (‘Student’) as prescribed I get a ‘could not compile expression’ error as shown:
This seems to happen sometimes when pulling from a web service, where the response is structured as array [*] object. I had tried a get in places across my pipeline, and hit similar issues. Im unclear on the usage and why this occurs, but get/getfirst seem limited to certain objects.
- cjhoward185 years agoEmployee
@acesario Sorry I forgot to format the expression so the quotes got bad formatting. Try this expression correctly formatted:
$.getFirst('Student').getFirst('Student_Data').getFirst('Student_Person_Data').getFirst('Personal_Profile_Data').Date_of_Birth