Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: json input with different fields (meta data injection)

  1. #1
    Join Date
    Jan 2017
    Posts
    2

    Default json input with different fields (meta data injection)


    I have several grouped parameters.

    Example:
    1.Group:
    table
    : channel
    field
    : via

    2.Group:
    table
    : ticket_tags
    field
    : tags

    And a following transformation. Till now I was able to execute everything only for the first group. But I want to generalize it, so that I read the file with the grouped parameters and the transformation executes for each set of the parameters. I assume I need meta data injection step. However, I am not sure how I should change the Fields/Path in json input to depict the variable from meta data injection, namely hub_field, for instance. For now I have there : $.ticket_events[].${hub_field}* , but it shows me an error:

    2017/01/0315:28:53- JSON Input.0-We can not find any data with path [$.ticket_events[*].${hub_field}]!

    The structure of the json file is:
    Code:
    {
      "end_time":1481672949,
      "ticket_events":[
    
        {
          "id":110831272025,
          "via":"Web Widget",
          "child_events":[
            {
              "event_type":"Create",
              "id":110831272085,
              "tags":[
                "web_widget"
              ]
            }
            ]
        }
        ]
    }
    

    So, I want the via field from ticket_events and tags field from ticket_events.child_events BUT viaand tags are comping from metadata injection via hub_field.


    And I have another transformation with only JSON Input which reads the json grouped parameters from above. The output is following:
    Last edited by akvarel; 01-03-2017 at 10:49 AM.

  2. #2
    Join Date
    Oct 2014
    Posts
    15

    Default

    You need to check out the samples of Metadata Injection,
    you should feed the Metadata injection transformation with the fieldname and other information that you would like to inject into the transformation you want to execute.

  3. #3
    Join Date
    Jan 2017
    Posts
    2

    Default

    Quote Originally Posted by qraforum View Post
    You need to check out the samples of Metadata Injection,
    you should feed the Metadata injection transformation with the fieldname and other information that you would like to inject into the transformation you want to execute.
    I though I did it already. In my ETL Metadata injection I get the following values:



    And I want to use hub_fields in my next JSON Input by inputing it in Fields-Path (of JSON Input) the following: $.ticket_events[*].${hub_field}. SO in the first case it would be $.ticket_events[*].via and in the second it would be $.ticket_events[*].tags.

    But it seems I cannot use the variable ${hub_field}

    So, basically what I want to do is to get variables from one json in order to select data according to those variables from another json.

    First json:

    Code:
    {
        "hubs_names":[
        {
            "name": "channel",
            "field": "via"
        },
        {
            "name": "ticket_tags",
            "field": "tags"
        }
    ]
    }
    I want to select name and field from the first json and store them in hub_name and hub_field.

    Then I want to use field as a variable in order to select data from second json.

    Second json:
    Code:
    {
      "end_time": 1481672949,
      "ticket_events": [
    
    
        {
          "id": 110831272025,
          "via": "Web Widget",
          "child_events": [
            {
              "event_type": "Create",
              "id": 110831272085,
              "tags": [
                "web_widget"
              ]
            }
            ]
        }
        ]
    }

    So, ..${hub_field} in first case ("via") it would give me "Web Widget" and in the second case ("tags") it would give me "web_widget".
    Last edited by akvarel; 01-03-2017 at 11:57 AM.

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

    Default

    Your main data is the second json file featuring some nested arrays.
    You want to extract all the tags of a child_event along with some information (via) from the ticket_event.
    To me, there's not much sense in making the JSONPath expressions generic.
    It's not just about fields, there's semantics involved after all.
    You can't just change from tags to some other field out of the blue.
    So what do you think you will get from generic expressions here?
    So long, and thanks for all the fish.

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.