Customer Portal

JSON reader mapping for Twitter JSON

Comments 5

  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hi Sandeep,

    The nested information should be of course sent to another output port, it can be done like this:
    <Context xpath="/root/object" outPort="0">
    <Mapping cloverField="md5" xpath="md5"/>
    <Mapping cloverField="original" xpath="original"/>
    <Context xpath="//metadata" outPort="1">
    <Mapping cloverField="resulttype" xpath="resulttype" />
    <Mapping cloverField="isolanguagecode" xpath="isolanguagecode"/>
    </Context>
    </Context>
    Regards,
  • Avatar
    sandeepbharmoria
    0
    Comment actions Permalink
    Thanks a lot!!

    This resolved my problem..

    There is new one I encountered:- if there are special characters involved in the "values" like

    "source": "<a href="http://www.twitter.com" rel="nofollow">Twitter for Windows Phone</a>"

    ETL throws an error during reading the json file.

    Is there any way to escape these character "<" ">" across the file?


    Regards

    Sandeep Thakur
  • Avatar
    sandeepbharmoria
    0
    Comment actions Permalink
    Further please find attached, mapping.xml,test.json and error_logs for above mentioned error..

    Please guide me how to remove this parsing error..

    Thanks

    Sandeep
  • Avatar
    imriskal
    0
    Comment actions Permalink
    I am sorry but if the JSON file contains the line you posted, it is not a valid JSON file and our readers can not process it. The issue is not in angle brackets, it is in quote marks delimiting both strings and attributes of html elements. If Twitter returns such output, you could report the issue there.

    FYI, here is an useful tool for JSON validation: http://jsonformatter.curiousconcept.com/

    Regards,
  • Avatar
    sandeepbharmoria
    0
    Comment actions Permalink
    Hi,

    I have resolved this problem with following code...


    Context xpath="/root/array" outPort="0">
    <Mapping cloverField="id" xpath="id" />
    <Mapping cloverField="text" xpath="text" />
    <Mapping cloverField="created_at" xpath="created_x005fat" />
    <Mapping cloverField="number1" xpath="geo/coordinates[1]"/>
    <Mapping cloverField="number2" xpath="geo/coordinates[2]"/>
    </Context>

Please sign in to leave a comment.