Fixed JSON parser(s)

This commit is contained in:
frikky
2020-10-14 12:15:53 +02:00
parent aae38c215b
commit b4976e32b3
2 changed files with 20 additions and 16 deletions
+7 -7
View File
@@ -370,13 +370,13 @@ type ExecutionRequestWrapper struct {
}
type AppExecutionExample struct {
AppName string `json:"app_name"`
AppVersion string `json:"app_version"`
AppAction string `json:"app_action"`
AppId string `json:"app_id"`
ExampleId string `json:"example_id"`
SuccessExamples []string `json:"success_examples"`
FailureExamples []string `json:"failure_examples"`
AppName string `json:"app_name" datastore:"app_name"`
AppVersion string `json:"app_version" datastore:"app_version"`
AppAction string `json:"app_action" datastore:"app_action"`
AppId string `json:"app_id" datastore:"app_id"`
ExampleId string `json:"example_id" datastore:"example_id"`
SuccessExamples []string `json:"success_examples" datastore:"success_examples,noindex"`
FailureExamples []string `json:"failure_examples" datastore:"failure_examples,noindex"`
}
// This might be... a bit off, but that's fine :)
+13 -9
View File
@@ -2531,14 +2531,16 @@ const AngularWorkflow = (props) => {
foundResult.result = foundResult.result.trim()
foundResult.result = foundResult.result.split(" None").join(" \"None\"")
foundResult.result = foundResult.result.split(" False").join(" false")
foundResult.result = foundResult.result.split(" True").join(" true")
foundResult.result = foundResult.result.split("\'").join("\"")
var jsonvalid = true
try {
const tmp = String(JSON.parse(foundResult.result))
if (!tmp.includes("{") && !tmp.includes("[")) {
jsonvalid = false
}
//if (!tmp.includes("{") && !tmp.includes("[")) {
// jsonvalid = false
//}
} catch (e) {
jsonvalid = false
}
@@ -2625,9 +2627,9 @@ const AngularWorkflow = (props) => {
var jsonvalid = true
try {
const tmp = String(JSON.parse(actionItem.example))
if (!tmp.includes("{") && !tmp.includes("[")) {
jsonvalid = false
}
//if (!tmp.includes("{") && !tmp.includes("[")) {
// jsonvalid = false
//}
} catch (e) {
jsonvalid = false
}
@@ -5344,13 +5346,15 @@ const AngularWorkflow = (props) => {
var showResult = executionData.execution_argument.trim()
showResult = showResult.split(" None").join(" \"None\"")
showResult = showResult.split("\'").join("\"")
showResult = showResult.split(" False").join(" false")
showResult = showResult.split(" True").join(" true")
var jsonvalid = true
try {
const tmp = String(JSON.parse(showResult))
if (!tmp.includes("{") && !tmp.includes("[")) {
jsonvalid = false
}
//if (!tmp.includes("{") && !tmp.includes("[")) {
// jsonvalid = false
//}
} catch (e) {
jsonvalid = false
}