Discussions

 View Only
  • 1.  How to access JSON object by key in Pipeline?

    Posted 11-02-2021 15:57
    I have mapped an object in my pipeline that grabs 4th and 5th object value, however, the order of the objects will not always be the same based on values we're passing into the pipeline. Is there a way to grab the value of an object based on the name of the key? For example, I would rather grab the value "vid" or "sid", but I understand those are values of the object. 

    I can get the vid value using: {{a.body_json.meta_data.4.value}}

    It's just not consistent, because it sometimes grabs the 5th or 6th object value based on what we pass. I was hoping there was a way to pull by key, but I couldn't get the syntax to work.

    I've tried the following for sid, but had no luck:
    {{a.body_json.sid}}
    {{a.body_json.meta_data.sid}}
    {{a.body_json.meta_data.0.sid}}
    {{a.body_json.meta_data.5.sid}}

    Help appreciated. Thanks!


    ------------------------------
    Quincy Adam
    ------------------------------


  • 2.  RE: How to access JSON object by key in Pipeline?

    Posted 11-03-2021 11:43
    It sounds like you're looking to search an array using a regex. 

    If the above is true, here are my 30 second thoughts for options:
    1. maintain the order of the array and include nils or blanks
    2. add processing to the pipeline to perform a search for each filter

    I would say maintaining an ordered array with nils is the preferred method.

    Do I know how? Nope.

    Curious to hear what you discover and results.

    ------------------------------
    Jim Harrison
    transparency = knowledge + understanding : The Scrum Dudes
    ------------------------------



  • 3.  RE: How to access JSON object by key in Pipeline?

    Posted 11-03-2021 15:22
    Thanks Jim. I'll have to explore nils, but I'm not sure how to accomplish, since we're accepting a direct web hook from Woocommerce.

    Adding a process to search through each filter is interesting, but I'm also not sure how to achieve that, since the documentation is very high level to this use case. I'll see what support can offer, but also wanted to past on the community since it's been helpful in the past. I'll follow-up if I get a solution.

    ------------------------------
    Quincy Adam
    ------------------------------