Six Stars

problem in data extraction from JSON file

I have the following JSON file at input and while extracting the data (using tExtractJSONFields, Readby: XPath) from the input file; I am getting only one record for the column status at output with value as "Viewed" but the status "Expired" goes missing and does not come at Target. May I know what did i do wrong and how to resolve so as to get 2 records that makes both the record to come at output. Any assistance is greatly appreciated.

{
        "_id": "abcd1234",
        "type": "assigned",
        "_time": {
            "stt": "2017-05-31T20:15:56.920Z",
            "tmn": "2017-04-04T16:47:51.669Z"
        },
        "assignedBy": "59235523cdb4446f2f95e583",
        "isPrivate": false,
        "status": [
            "viewed",
            "expired"
        ],
        "confirmationStatus": "",
        "completedTime": "0001-01-01T00:00:00",
        "milestones": [
            {
                "title": "Week 1",
                "completeBy": "2017-06-09T00:00:00Z",
                "completedDate": "0001-01-01T00:00:00"
            },
            {
                "title": "Week 2",
                "completeBy": "2017-06-09T00:00:00Z",
                "completedDate": "0001-01-01T00:00:00"
             },
        ],
        "searchableTitle": "Title123",
        "_acl": {
            "creator": "avcbbde123",
            "gr": false,
            "gw": false,
            "groups": {
                "r": [
                    "abcde12345"
                ],
                "w": [
                    "uvwxyz6789"
                ]
            }
        },
        "count": 672
    }
Tags (1)
5 REPLIES
Community Manager

Re: problem in data extraction from JSON file

Hi
Any other elements do you want to parse and extract value? Or you just want to extract value of status element? How do you set the Loop xpath query?

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: problem in data extraction from JSON file

Hello

Do you want to extract 2 lines with the same data, but for one the status should be viewed and the other expired, right?

Please find the image attached, maybe it could helps you.

 

Thanks

DouglasScreen Shot 2017-07-18 at 11.30.03.png

 

 

Six Stars

Re: problem in data extraction from JSON file

sorry for the delayed response,

in the attached screenshot, if i am having 2 different values at status viz., viewed, expired; I am getting only one value. can you please let me know how can both the value be extracted and the result should have 2 rows; each row containing each value of status all the other remains the same.

 

event_status_error.png

 

Also there is another problem which I encountered recently; different loop xpath query yields different rows from input. For Eg: if loop xpath query is based on title i am getting different no of rows compared to the loop xpath query that is based on /_acl/groups. Can you please let me know how is that possible and how to eliminate such differences while extracting the data from source.

Six Stars

Re: problem in data extraction from JSON file


douglaszickuhr wrote:

Hello

Do you want to extract 2 lines with the same data, but for one the status should be viewed and the other expired, right?

Please find the image attached, maybe it could helps you.

 

Thanks

DouglasScreen Shot 2017-07-18 at 11.30.03.png

 

 


if i use status in loop xpath query, i am getting lesser no. of records than that of using another field in xpath query.

Six Stars

Re: problem in data extraction from JSON file


sreenathtr wrote:

sorry for the delayed response,

in the attached screenshot, if i am having 2 different values at status viz., viewed, expired; I am getting only one value. can you please let me know how can both the value be extracted and the result should have 2 rows; each row containing each value of status all the other remains the same.

 

event_status_error.png

 

Also there is another problem which I encountered recently; different loop xpath query yields different rows from input. For Eg: if loop xpath query is based on title i am getting different no of rows compared to the loop xpath query that is based on /_acl/groups. Can you please let me know how is that possible and how to eliminate such differences while extracting the data from source.


The difference in record count happens when there is no data or no value inside that particular xpath loop query for that element hence that record gets discarded.

 

I guess, we need to select maximum level of depth as the absolute path, only then only the JSON will get converted in RDB format. If we choose, as said above we encounter 2 issues

 

  1. different values are not coming (column Status)
  2. If the data inside the path is null then whole record is ignore

How to have more than one row if the status having more than 1 value and if there is no value in status; get that particular record to output with other column present (in which column status alone is null)