Welcome to the Make community!
You can use a Text Parser “Replace” module with this Pattern (regular expression):
"fields":\s+{(?<fields>[\w\W]+?)}
Proof
https://regex101.com/r/QirD7V
Important Info
- Global match must be set to YES!
Screenshot
Output
For more information, see Text Parser in the Make Help Center:
Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.
Hope this helps!
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.
-
Click on each imported module and save it. You may need to remap some variables.
Modules JSON Export
{
"subflows": [
{
"flow": [
{
"id": 5,
"module": "regexp:Replace",
"version": 1,
"parameters": {},
"mapper": {
"pattern": "\"fields\":\\s+{(?<fields>[\\w\\W]+?)}",
"value": "$1",
"global": true,
"sensitive": true,
"multiline": false,
"singleline": false,
"text": "{\n \"body\": {\n \"records\": [\n {\n \"id\": \"recrsBYQ\",\n \"createdTime\": \"2024-09-06T10:22:21.000Z\",\n \"fields\": {\n \"fields1\": \"xyz\",\n \"fields2\": true\n }\n },\n {\n \"id\": \"rec123XYZ\",\n \"createdTime\": \"2024-09-07T12:00:00.000Z\",\n \"fields\": {\n \"fields1\": \"abc\",\n \"fields2\": false\n }\n }\n ]\n }\n}\n"
},
"metadata": {
"designer": {
"x": -21,
"y": 398,
"messages": [
{
"category": "last",
"severity": "warning",
"message": "A transformer should not be the last module in the route."
}
]
},
"restore": {
"expect": {
"global": {
"mode": "chose"
},
"sensitive": {
"mode": "chose"
},
"multiline": {
"mode": "chose"
},
"singleline": {
"mode": "chose"
}
}
},
"expect": [
{
"name": "pattern",
"type": "text",
"label": "Pattern",
"required": true
},
{
"name": "value",
"type": "text",
"label": "New value"
},
{
"name": "global",
"type": "boolean",
"label": "Global match",
"required": true
},
{
"name": "sensitive",
"type": "boolean",
"label": "Case sensitive",
"required": true
},
{
"name": "multiline",
"type": "boolean",
"label": "Multiline",
"required": true
},
{
"name": "singleline",
"type": "boolean",
"label": "Singleline",
"required": true
},
{
"name": "text",
"type": "text",
"label": "Text"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}