Customer Portal

JSON reader mapping for Twitter JSON

Comments 1

  • Avatar
    slechtaj
    0
    Comment actions Permalink
    Hi Markovich,

    If your task is to map these fields to two different output ports, the task is pretty easy. In JSONExtract, there is a graphical mapping interface in which you will map these elements to particular fields and ports. Please refer to attached example for more information.
    However, if you would like to get these data on one record, the situation would be slightly more complicated. Basically you would have two options, where the second one is based on the aforementioned approach.

    • Using JSONReader
      You will prepare XPATH mapping for your data. Where the first element of „response“ array is the number you want to extract („806“ value) and map to the first field of output record; and the second element of the same array is an array that contains „text“ element whose value you want to map to the second output field. The XPATH may look like this:
      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <Context xpath="/root/object" outPort="0">
      <Mapping cloverField="number" xpath="//response[1]"/>
      <Mapping cloverField="text" xpath="//response[2]/text"/>
      </Context>


    • Using JSONExtract
      The second option is to use above mentioned mapping dialog and map data to two different output ports. You will see that record counts on the both edges are different. However, if the format of the JSON is always the same, you can be sure that the first records on these edges are those you want to merge into one record. For this purpose, there is a component called Combined (needs to be configured based on your needs – e.g. incomplete tuples allowed, and make sure only complete tuple is sent to output port).



    See the attached example to see aforementioned approaches.
    ExtractJSON.grf
    Hope this helps.

Please sign in to leave a comment.