From 75107143868e43959bf275b029e371a5dab1d61c Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 11 Dec 2014 11:22:39 -0500 Subject: [PATCH] ToJSON fix Expanded the list of things the ToJSON method can accept --- awx/ui/static/js/helpers/Variables.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/ui/static/js/helpers/Variables.js b/awx/ui/static/js/helpers/Variables.js index b8d2226201..f318407c2b 100644 --- a/awx/ui/static/js/helpers/Variables.js +++ b/awx/ui/static/js/helpers/Variables.js @@ -88,7 +88,7 @@ angular.module('VariablesHelper', ['Utilities']) if (parseType === 'json') { try { // perform a check to see if the user cleared the field completly - if(variables === "" ){ + if(variables.trim() === "" || variables.trim() === "{" || variables.trim() === "}" ){ variables = "{}"; } //parse a JSON string @@ -104,10 +104,11 @@ angular.module('VariablesHelper', ['Utilities']) $log.error('Failed to parse JSON string. Parser returned: ' + e.message); ProcessErrors(null, variables, e.message, null, { hdr: 'Error!', msg: 'Failed to parse JSON string. Parser returned: ' + e.message }); + throw 'Parse error. Failed to parse variables.'; } } else { try { - if(variables === ""){ + if(variables.trim() === "" || variables.trim() === "-" || variables.trim() === "--"){ variables = '---'; } json_data = jsyaml.load(variables);