2

Accessing JSON Data that have Keys with Spaces

Whether it be a bug or my ignorance to common JSON practices, I found out today that parsing JSON objects into my Klips won't work unless the keys do not have spaces.  The solution was to use the contains() function rather than call the key for the field I was trying to display.

BEFORE 

AFTER

4 comments

  • 0
    Avatar
    Larona Nyambe

    Hi Will,

    Thanks for posting in our community. What you have uncovered is not a bug, json elements whose names begin with non-alphabetic characters cannot be selected directly. See example 4 on this doc: https://support.klipfolio.com/hc/en-us/articles/215547118-About-JSON-and-XML-data-sources 

    Your solution is perfect. 

    Cheers

  • 0
    Avatar
    Daniel Verstegen

    This seems like a bug. I am unable to select using a key with non-alphabetic chars.

    The following does not work:

    @data[name()='123_long_key_starts_with_numeric_char'];

    While the docs say this: @day[name()='@date'] should work.

    Is it because it starts with a number?

     

    edit:

    contains() trick works well though : )

     

  • 0
    Avatar
    Josh Cohen-Collier

    Hi Daniel,

    Sorry for the inconvenience here.

    Would you mind if we created a support ticket for this issue?
    Without seeing the actual underlying datasource, it would be difficult to say what the correct XPath would be.

    Warm regards,
    Joshua

  • 0
    Avatar
    Leann Lewis

    Ran into the same issue Daniel V. did. I'm not sure if the solution is the same but I figured I'd toss up a comment in case anyone else came here looking for this. The knowledge base article gives an example of selecting an attribute node that doesn't begin with an alphabetic character. The method the article give doesn't work with element nodes, though.

    To select an element node by name this way I had to add a wildcard (*) before the [name()=('1string')].

    For example, this did not work:

    @employees/[name()=('-13')]

    But this did:

    @employees/*[name()=('-13')]

Please sign in to leave a comment.