Better way of getting values instead of Transform to JSON -> Parse JSON

:bullseye: What is your goal?

I want to fetch the KM Price in the first collection of the body in the first bundle using code and not extra modules.

:thinking: What is the problem & what have you tried?

I can use transform it to JSON and use first(toArray(Body)) and then parse it but it is ticking 2 extra operations everytime. This is a scenario that has around 20.000 operations per month so want to optimize it as far as possible. Have tried to use map to get the value but can not get it to work

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hi @Fredrik_Trogen.

I’m not sure if I understood your question, but it looks like your Body Collection contains another Collection (10), and it has a property called Km Price. There are no arrays involved, as far as I can see.

Why exactly can’t you reference Km Price directly? Something like {{X.<covered collection>.body.10.km_price}} (check raw field names).
Did you set the HTTP module to “Parse Response” = Yes?
Where are you trying to use map()?

Hey Fredrik,

on top of what damato said. This is also already a parsed JSON as well so why transform it too?

There is no reason for you not to be able to access this variable directly. You don’t need to transform the bundle to a JSON again or to do anything with arrays, since there aren’t any.

1 Like

Hi @Stoyan_Vatov @damato

I was not clear enough

The body consist of many collections. I need to fetch the collection with the newest valid from date to get actual km price

You mean something like this, considering Body is an array:

{{get(sort(X.Body;desc;_dataTimestamp);1)}} :red_question_mark:

1 Like

Hi, another example to explain better. I get this response. I need to find the km price for the newest collection (based on _dataTimestamp) in the Data collection. So in below example what I want is the value 1.23

Assuming the RAW key name for “Km Price” is _kmPrice (because you took a screenshot and did not provide the output bundle as TEXT here),

You can use these built-in functions:

  • toArray
    toArray(collection)

  • sort
    sort(array; [order]; [key])

  • map
    map(complex array; key; [filter by key]; [csv-values for filtering])

  • first
    first(array)

These functions may have also been covered in the Make Academy tutorials — refer to the Make Academy Course Overview to learn more.

Here’s an example of how you can use these functions together:

{{first(map(sort(toArray(194.data); "desc"; "value._dataTimestamp"); "value._kmPrice"))}}
:warning: Make Input Markup:
        Copy-paste the above into the field, including start/end curly brackets for it to import as intended

E.g.:

Module Subflow Export - paste modules into your scenario

Copy and paste this into the scenario editor to import the example modules shown in my screenshots above.

{"subflows":[{"flow":[{"id":194,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"{\r\n  \"data\": {\r\n    \"4\": {\r\n     \"_ragicId\": 4,\r\n     \"_star\": false,\r\n     \"_dataTimestamp\": 1773991306956,\r\n     \"_validFrom\": \"2026/01/01\",\r\n     \"_index_calDates_\": \"d1001423 2025/01/01\",\r\n     \"_kmPrice\": 1.17,\r\n     \"comment\": \"\",\r\n     \"_index_title\": \"\",\r\n     \"_index_\": \"\",\r\n     \"_seq\": 2\r\n    },\r\n    \"5\": {\r\n     \"_ragicId\": 5,\r\n     \"_star\": false,\r\n     \"_dataTimestamp\": 1773590406956,\r\n     \"_validFrom\": \"2026/03/16\",\r\n     \"_index_calDates_\": \"d1001423 2026/03/16\",\r\n     \"_kmPrice\": 1.23,\r\n     \"comment\": \"\",\r\n     \"_index_title\": \"\",\r\n     \"_index_\": \"\",\r\n     \"_seq\": 1\r\n    }\r\n  }\r\n}"},"metadata":{"designer":{"x":125,"y":-2539},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":195,"module":"util:SetVariable2","version":1,"parameters":{},"mapper":{"name":"latestKmPrice","scope":"roundtrip","value":"{{first(map(sort(toArray(194.data); \"desc\"; \"value._dataTimestamp\"); \"value._kmPrice\"))}}"},"metadata":{"designer":{"x":425,"y":-2539}}}]}],"metadata":{"version":1}}
Need help❓View instructions ◀

1. Move your mouse over the line of code above.
Copy the JSON by clicking the copy button on the right-side:

2. Enter your scenario editor. Close any open panels by pressing ESC. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

3. Click on imported modules and re-save it to trigger validation. There may be some errors prompting you to re-map some variables and select connections.

Note: Did you know you can also reduce the size of blueprint exports and module subflows like the above, using my Make Blueprint Scrubber?

— @samliew

1 Like

If you are still having trouble, please provide more details.

Do NOT take another screenshot!

Please provide the Output bundle of each of the relevant modules from the Scenario History, or by re-running the scenario.

Expand Instructions â—€

Click on the white speech bubbles on the top-right of each module and select “Download output (or input) bundles”.

A. Upload a Text File

Save each bundle contents in a plain text editor as a moduleNumber-output.txt file. Open the file to check if it has not added additional formatting or encoded the plain text.

  • You can upload files and images to this forum by clicking on the upload button:

    Uploading an attachment here will look like this:
    module1-input.txt (1.2 KB), module1-output.txt (3.4 KB)

B. Insert a Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the bundles AND format them correctly with the “Preformatted Text” (code) button in the rich-text editor. Otherwise the forum software will change the content, making them invalid!

:warning: Formatting IS Important! :warning:

Here are some ways to provide text content in a way that it won’t be modified by the forum.

  • Method 1: Type code fence manually —
    Manually type three backticks ``` in a separate line before and after the content, like this,

    ```
    text goes here
    ```
    
  • Method 2: Highlight the pasted content, then click the preformatted text/code button —

  • Method 3: Upload your file elsewhere and share the public link —
    This method is only advised for large files exceeding the forum upload limit.

Providing the Output bundle will allow others to replicate what is going on, especially if there are complex data structures (like nested arrays and collections) and data from external services. This helps us with answering your question with valid examples, like mapping raw variable names (instead of the label/display name).


This will allow others to better assist you. Thanks!

— @samliew

Thanks. Works like a charm

1 Like

No problem, glad I could help with your question:
"Better way of getting values instead of Transform to JSON → Parse JSON"   :tada:

Next time, please provide your output bundles as formatted text, to get answers faster.

1. Which was the most helpful post in this thread?

The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep this forum organised. :folded_hands:

This marks the topic as solved, so that others can:

  • save time when browsing the latest activity on the forum, and
  • quickly jump to the solution in this topic (from the top)

To do this, simply click the checkbox at the bottom of the post that is the most helpful in answering your question.

a screenshot of post menu options at the bottom of each post
:link: Here’s a magic link to a list of your other “unsolved” topics— status:unsolved

2. Have you learnt something new?

Do bookmark this topic so you can easily find and return to this topic in future.
a screenshot of bookmark link at the bottom of the topic

:link: Here’s a magic link to a list of your bookmarks— /my/activity/bookmarks

3. Have a different question? Start a new topic.

Do you have a question that is not about "Better way of getting values instead of Transform to JSON → Parse JSON"? Please start a new topic.

Creating a separate topic for each question makes it easier for others with the same problem to search for answers. You are also more likely to receive help sooner as new topics are displayed first on the forum’s “new” page!

— @samliew