IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Flattening and Multiple Types Options · View
cmisztur
Posted: Tuesday, February 28, 2017 3:00:44 PM
Rank: Newbie

Joined: 5/4/2013
Posts: 9
Location: Chicago


I have two questions:

1. How do I flatten the results from the 'readResults' array such that my output could just be '{id} = {v}' (eg. 'Something' = 555).

2. How to deal with multiple types of the 'v' property? Sometimes 'v' will be a string, number, or bool.... Using the string type returns nothing, but the number type does. I thought using the string type would just cast whether it is numeric or bool.

Thanks
Chris
vlad
Posted: Tuesday, February 28, 2017 3:48:23 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
1) your question is not clear, and your mapping attempt feels like an overkill, but in order to be sure provide some sample input and output

2) in contrary to XML, strings in JSON have different syntax from numbers, therefore you do not get the values from string as you can do in XML. A simple workaround is to use the function substitute-missing, and connect string to "node" and number to "replace-with" - this should do the thing
cmisztur
Posted: Tuesday, February 28, 2017 4:28:09 PM
Rank: Newbie

Joined: 5/4/2013
Posts: 9
Location: Chicago
1) Yes it is overkill. Here is the input and expected output...
http://i.imgur.com/sllIVxJ.jpg

2) Let me try that.

/c
vlad
Posted: Tuesday, February 28, 2017 5:31:26 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
See 2 screenshots below. The mapping on first screenshot produces result on second. For output I used a text component with a single column


vlad attached the following image(s):
mapping.PNG
result.PNG

cmisztur
Posted: Tuesday, February 28, 2017 6:04:43 PM
Rank: Newbie

Joined: 5/4/2013
Posts: 9
Location: Chicago
Very cool vlad.

How would you now serialize this down to a single output result so that MFServer API could return back to calling client?

/c
vlad
Posted: Tuesday, February 28, 2017 6:08:47 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
Many ways possible - one of them the File/String button in output. Read documentation for more details.
cmisztur
Posted: Tuesday, February 28, 2017 6:15:50 PM
Rank: Newbie

Joined: 5/4/2013
Posts: 9
Location: Chicago
ah Yes.... that button.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.