How to extract a specific vallue from a string

:bullseye: What is your goal?

II want to pass values from Amelia to Active Campaign, however the custom fields are all grouped up in a single string: {“1”:{“label”:“Codice Fiscale”,“type”:“text”,“value”:“STRLND93C47Z154G”},“3”:{“label”:“Sesso”,“type”:“select”,“value”:“Donna”},“6”:{“label”:“Indirizzo”,“type”:“address”,“value”:“Via Andrea Del Sarto 32”},“15”:{“label”:“Acconsento all’informativa sulla Privacy”,“type”:“checkbox”,“value”:[“S\u00ec”]},“17”:{“label”:“Voglio ricevere offerte e promozioni”,“type”:“select”,“value”:“Via Email, SMS e Whatsapp”}}

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

I wanted to build a formula like this, but it seems it doesn’t allow it get(
parseJSON( 1.appointment.bookings[0].customer.customFields )
; “1.value”
)

I basically need to extract all the fields from the string to make them single variables

1 Like

Hey Aleksandra,

that’s already a collection of items and you should be able to access them. No need for a get() function here, since this is not an array. If this is what the output looks like, just feed it to a parse JSON module and you will get the variables.

1 Like

Hi Stoyan, I tried that but the outcome is not right.

1 Like

Welcome to the Make community!

Firstly,

You cannot individually run a single module if you don’t have example input data values for each required field, which you must input into the dialog box when you manually run a single module. This is because when you only run a specific module, the mapped variables in the module’s fields are null (do not contain any value), as the previous modules do not run and produce any variable values. Does this make sense?

Instead, try running the full scenario by clicking the “Run Once” button:

Next,

Looks like you have JSON nested within a JSON response. This means you have to pass the “customFields” variable into a Parse JSON module.

If you need further assistance with this, please provide the input/output bundles of the trigger modules by running the scenario, or get the bundles from a previous run from the Scenario “History” tab.

Providing the bundles from a scenario run will allow others to replicate what is going on, especially if there are complex data structures (nested arrays and collections) and external services. This helps mapping the correct raw variable names from collections (instead of the label/display name).

Need help❓View 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.

: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.

This will allow others to better assist you. Thanks!

@samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!