Added automated parsing of subvalues in JSON to make even more values into proper usable keys
This commit is contained in:
@@ -12021,11 +12021,7 @@ const parsedExecutionArgument = () => {
|
||||
<CircularProgress />
|
||||
) : (
|
||||
executionData.results.map((data, index) => {
|
||||
if (
|
||||
executionData.results.length !== 1 &&
|
||||
!showSkippedActions &&
|
||||
(data.status === "SKIPPED")
|
||||
) {
|
||||
if (executionData.results.length !== 1 && !showSkippedActions && (data.status === "SKIPPED") ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12409,15 +12405,14 @@ const parsedExecutionArgument = () => {
|
||||
? ""
|
||||
: validateJson(selectedResult.result.trim());
|
||||
|
||||
console.log("RESULT: ", validate.result)
|
||||
if (validate.valid && typeof validate.result === "string") {
|
||||
console.log(validate.result)
|
||||
validate.result = JSON.parse(validate.result);
|
||||
}
|
||||
|
||||
const AppResultVariable = ({data}) => {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const showVariable = data.value.length < 60
|
||||
console.log("Value: ", data.value)
|
||||
|
||||
return (
|
||||
<div style={{maxWidth: 600, overflowX: "hidden", }}>
|
||||
|
||||
@@ -394,32 +394,23 @@ const chipStyle = {
|
||||
};
|
||||
|
||||
export const validateJson = (showResult) => {
|
||||
//console.log("INPUT: ", showResult, typeof showResult)
|
||||
console.log("INPUT: ", showResult, typeof showResult)
|
||||
if (typeof showResult === 'string') {
|
||||
//showResult = showResult.split(" None").join(" \"None\"")
|
||||
showResult = showResult.split(" False").join(" false");
|
||||
showResult = showResult.split(" True").join(" true");
|
||||
//return {
|
||||
// valid: false,
|
||||
// result: showResult,
|
||||
//};
|
||||
showResult = showResult.split(" False").join(" false")
|
||||
showResult = showResult.split(" True").join(" true")
|
||||
}
|
||||
|
||||
//if (typeof showResult === undefined) {
|
||||
|
||||
//}
|
||||
|
||||
if (typeof showResult === "object" || typeof showResult === "array") {
|
||||
return {
|
||||
valid: true,
|
||||
result: showResult,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var jsonvalid = true;
|
||||
var jsonvalid = true
|
||||
try {
|
||||
if (!showResult.includes("{") && !showResult.includes("[")) {
|
||||
jsonvalid = false;
|
||||
jsonvalid = false
|
||||
}
|
||||
} catch (e) {
|
||||
showResult = showResult.split("'").join('"');
|
||||
@@ -464,6 +455,32 @@ export const validateJson = (showResult) => {
|
||||
jsonvalid = false
|
||||
}
|
||||
|
||||
console.log("RES: ", result)
|
||||
// This is where we start recursing
|
||||
if (jsonvalid) {
|
||||
// Check fields if they can be parsed too
|
||||
try {
|
||||
for (const [key, value] of Object.entries(result)) {
|
||||
if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) {
|
||||
console.log("INSIDE: ", key, value);
|
||||
const inside_result = validateJson(value)
|
||||
console.log("Inside: ", inside_result)
|
||||
if (inside_result.valid) {
|
||||
console.log("Replacing value since it's valid JSON!")
|
||||
if (typeof inside_result.result === "string") {
|
||||
const newres = JSON.parse(inside_result.result)
|
||||
result[key] = newres
|
||||
} else {
|
||||
result[key] = inside_result.result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Failed parsing inside json subvalues: ", e)
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("VALID: ", jsonvalid, result, typeof result)
|
||||
return {
|
||||
valid: jsonvalid,
|
||||
|
||||
Reference in New Issue
Block a user