Skip to content

Commit 078c4ca

Browse files
committed
chore: revert changes to jsonaction and replaceplaceholderswithvalues
1 parent 99bafd7 commit 078c4ca

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

kleros-sdk/src/dataMappings/actions/jsonAction.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ import { createResultObject } from "src/dataMappings/utils/createResultObject";
33

44
export const jsonAction = (mapping: JsonMapping) => {
55
const { value: source, seek, populate } = mapping;
6-
const sourceData = JSON.parse(source);
7-
8-
return createResultObject(sourceData, seek, populate);
6+
return createResultObject(source, seek, populate);
97
};

kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ export const replacePlaceholdersWithValues = (mapping: any, context: any) => {
33

44
const replacedMapping = mappingAsString.replace(/\{\{(\w+)\}\}/g, (_, variableName) => {
55
if (context.hasOwnProperty(variableName)) {
6-
const value = context[variableName];
7-
8-
if (typeof value === "string" && value.startsWith("{") && value.endsWith("}")) {
9-
return JSON.stringify(value);
10-
} else {
11-
return typeof value === "bigint" ? value.toString() : value;
12-
}
6+
return context[variableName];
137
} else {
148
throw new Error(`Variable '${variableName}' not found in context.`);
159
}
1610
});
1711

18-
const parsedMapping = JSON.parse(replacedMapping.replace(/"(\{.*\})"/, "$1"));
19-
return parsedMapping;
12+
return JSON.parse(replacedMapping);
2013
};

0 commit comments

Comments
 (0)