Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: JSON Input and sub-nodes

  1. #1
    Join Date
    Jul 2013
    Posts
    8

    Default JSON Input and sub-nodes

    Please disregard the post below. I have simply confused the IDs for one another, Kettle does load the root id by default. Then again, just out of pure interest by now, how could you get specifically "listing/id" from the JSON below? Just out of curiousity.

    I am not an expert when it comes to JSON, but so far I managed to tackle every problem that had arisen. This one, however, stopped me dead.

    I have a JSON Input step that receives something like:
    Code:
    {
       "birthplace": "alaska",
       "listing": [
          {
             "id": "456",
             "rank": "CEO"
          }
       ],
       "id": "123",
       "name": "xyz",
    }
    And so I am trying to retrieve the 'id' field. The main id field, in fact. Which is "123". However, the JSON Input step returns the value "456" because logically that is the first "id" field it encounters. Unfortunately I have no control over the source input itself, which is often varied.

    Can you help me on how can I ensure that the JSON Input step returns only the ROOT id field? In fact, parsing the subnodes isn't even necessary as I have no use for them.
    Last edited by BBalazs; 12-13-2013 at 04:49 AM. Reason: A stupid mistake.

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

    Default

    The JSONPath expression would be "$.listing[0].id"
    So long, and thanks for all the fish.

Tags for this Thread

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.