Skip to content
Transforming JSON i...
 
Notifications
Clear all

Transforming JSON into desired fields

3 Posts
2 Users
0 Reactions
3 Views
NWE
 NWE
(@nwe)
Posts: 2
New Member
Topic starter
 

Hello everyone,

I'm currently working on extracting specific fields from a blueprint API call. This API call can be accessed via the following URL: https://eu1.callin.io/api/v2/scenarios/SCENARIO_ID/blueprint . When invoked, it returns a substantial amount of data from the scenario blueprint, which is useful for export or import purposes.

My goal, however, is to isolate only the essential items from the JSON response and then send this curated data to either OpenAI or Anthropic, depending on the token count. The intention is to generate documentation for the scenario or provide an explanation of its functionality.

I'm facing challenges with data mapping. Within the blueprint.flow section, there's an array of modules, and each module contains several collections. The specific information I need is located within the mapper collection, and I want to exclude metadata and parameters. Given that blueprints can vary significantly, it's not practical to map each value individually or to solely focus on the mapper collection (please see the attached screenshot).

Therefore, I'm looking for advice on how to transform the data into my own JSON format, enabling me to exclude all the 'unnecessary' fields. This is crucial because the extensive data either exhausts the available tokens or overwhelms the AI due to its complexity.

Any assistance would be greatly appreciated.

 
Posted : 22/05/2023 8:41 am
Runcorn
(@runcorn)
Posts: 16
Active Member
 

Hi,

I'm not entirely sure about your specific use case, but working with JSON data that has an undefined structure can indeed be challenging, and I'm not certain if it's directly achievable.

However, if you know the structure of the JSON you'll receive in your module beforehand, here's a potential approach:

  1. From the Blueprint response, you can fetch all mappers associated with the __http:ActionSendData module. To do this, you can utilize the map function directly. Then, within the filter, you can specify contentType as application/json. While it's possible to achieve this with another map function, it might become quite intricate.


    {{map(1.data.flow; “mapper”; “module”; “http:ActionSendData”)}}

    In this snippet, data.flow would refer to your blueprint's flow.

  2. Insert a filter step to verify that the contentType of the iterator's result is application/json.

  3. Subsequently, add a Parse JSON module to process the data body.

Your workflow should resemble something like this:

Screenshot from 2023-05-22 15-54-49

 
Posted : 22/05/2023 10:11 am
NWE
 NWE
(@nwe)
Posts: 2
New Member
Topic starter
 

Thanks for the explanation, but I believe that's precisely the problem, as you noted:

Working with JSON whose data structure is not predefined can be tricky, and I'm not sure if that is achievable. However, if you know beforehand the structure of the JSON you will have in your module, then what you can do is:

I don't know the structure of the JSON because I'd like to do this with all my scenarios, and the possible JSON structures are as numerous as callin.io has integrations.

 
Posted : 22/05/2023 2:38 pm
Share: