Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: First time using JSON Input and having problems

  1. #1
    Join Date
    May 2016
    Posts
    6

    Unhappy First time using JSON Input and having problems

    {
    "responses": [
    {
    "1": {
    "id": "1",
    "datestamp": "2017-01-25 16:46:57",
    "q22567": "15900",
    "q22578": "70",
    "q20877": "100",
    "q20907[14862]": "Y",
    "q20907[14863]": "Y",
    "q20907[14524]": "",
    "q20907[14597]": "",
    "q20909": "100",
    "q8931": "71",
    "q20956": "14876"
    }
    }
    ]
    }

    That is the JSON file that I am reading. I have two JSON Inputs with the first one having a name of responses and a path of $.responses[*].[*]. The second one then has 'Source defined in a field?' ticked and responses in the 'Get source from field'. Under fields I am having no problems writing to an Excel file using these paths: $..id, $..datestamp, $..q22578, etc..

    My problem is coming from the 4 records that have brackets. I have tried for the last two hours trying to add q20907[14862] as the next field but I cannot get the path. I have tried $..[5], $..20907[14862], $..20907[0], and many others. Any help with the path for these four would be appreciated.

    I am using GAR 6.1.0.1-196 and the error I am getting is the 'The data structure is not the same inside the source!.............'

  2. #2
    Join Date
    Aug 2011
    Posts
    236

    Default

    Hi,

    You basically have to have two JSON input components in a row. To process the 'q20907' you need to have it as a pass-through value in the first JSON input and then you can get values from it in the second JSON input.

    HTH.


    PDI 8.0.0
    MySQL - 5.6.27
    Redshift - 1.0.1485
    PostgreSQL 8.0.2
    OS - Ubuntu 10.04.2

  3. #3
    Join Date
    May 2016
    Posts
    6

    Default

    I do have two in a row. The first one is the one where I was talking about having a path with $.responses[*].[*] in it. Do I need to add another name and path right below that one pulling the 'q20907' fields? What would be the path I would use if that is the case?

    Thank you....

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Pentaho switched to Jayway/JsonPath (see bracket-notated children) with Kettle 7.0, so there's no restriction on keynames as in the previous parser anymore.
    Attached Files Attached Files
    So long, and thanks for all the fish.

  5. #5
    Join Date
    May 2016
    Posts
    6

    Default

    Thank you marabu. Downloaded Kettle 7.0 and used your example and everything is working as needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.