Customer Portal

JsonExtract could not read elements having SPACE

Comments 6

  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hello Madan_clover3,
    in order to resolve the issue, please replace “phone numbers” in your mapping with “phone_numbers”. The reason why the underscore needs to replace the space symbol in the mapping is that Clover internally converts JSON into XML and the space symbol is not a valid character in XML. When using the visual mapper within the JSONExtract component, it gets replaced automatically.
    Kind regards,
  • Avatar
    madan_clover3
    0
    Comment actions Permalink
    please replace “phone numbers” in your mapping with “phone_numbers” : 'phone numbers' represents element in json data file. Replacing in mapping file is enough? We might need to change in data file as well. Data file is not in our control, it is user uploaded file. Yeah space is invalid in xml elements, but is valid in json elements. So Can I conclude JsonExtract has a limitation of reading elements with space? Please update
  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hello Madan_clover3,
    yes, replacing the space symbol with an underscore in the mapping is enough for your graph to work properly. In other words, no changes need to take place in the input file. As you rightly said, the space symbol is indeed a valid character in JSON. However, due to the way how CloverETL is currently designed to work (it internally converts JSON into XML before the parsing itself) the mapping needs to fulfill the XML standards.
    As I mentioned in my previous post, JSONExtract is intended for usage as a visual mapping tool in the first place and the underscore replacement happens automatically. So to answer your last question, JSONExtract does not have a limitation in reading elements with spaces, it just requires to avoid spaces in the mapping which is not a concern for most users.
    Best,
  • Avatar
    madan_clover3
    0
    Comment actions Permalink
    What if json source file contains two elements like 'abc xyz'(with space) and 'abc_xyz'(with underscore) and these 2 source elements are mapped to 2 different target elements. How it behaves in the above case, please clarify.
  • Avatar
    Vladimir Barton
    0
    Comment actions Permalink
    Hello Madan_clover3,
    in such a scenario, the JSONExtract component would not be a good candidate for the parsing. Due to the fact, that the space character " " is automatically replaced by the underscore "_" both elements would fuse into a single one ("abc_xyz") and their respective values would be mixed. I have logged this issue into our JIRA so that it gets reviewed and addressed by our development team.
    A workaround solution to this problem is to utilize the JSONReader component where both space and underscore characters are replaced by escaped character sequences. Attached is an example graph where I have used a slightly modified version of your sample input file.
    Kind regards,
    Vladi
  • Avatar
    kaduswapnali456
    0
    Comment actions Permalink
    Great topic! Excellent answers. Got solution. Thank you for the answers.

Please sign in to leave a comment.