Skip to main content
Best Answer

JSONTemplator - Cast value types from a list?

  • August 20, 2020
  • 2 replies
  • 7 views

virtualcitymatt
Celebrity
Forum|alt.badge.img+47

I have a list attribute that I'd like to use in a JSONTemplator. I am able to get the list into an array no issues, however, I want the result to be an array of integers/numbers rather than a string. If it was not a list I can use the xs:integer to try to force it to be an integer, however, I'm not quite sure how I should do this for values in a list. Any ideas on this?

Best answer by takashi

Hi @virtualcitymatt​ , a possible way is to use an XQuery expression like this. Assuming that every element of the list represents integer value.

[
    for $v in fme:get-list-attribute('_list{}.number')
    return xs:integer($v)
]

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • Best Answer
  • August 20, 2020

Hi @virtualcitymatt​ , a possible way is to use an XQuery expression like this. Assuming that every element of the list represents integer value.

[
    for $v in fme:get-list-attribute('_list{}.number')
    return xs:integer($v)
]

 


virtualcitymatt
Celebrity
Forum|alt.badge.img+47

Hi @virtualcitymatt​ , a possible way is to use an XQuery expression like this. Assuming that every element of the list represents integer value.

[
    for $v in fme:get-list-attribute('_list{}.number')
    return xs:integer($v)
]

 

And that is why they call you the best. Thanks @Takashi Iijima​ .