Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for true JSON values in PUT and POST data. Previously J…

…SON data would be double-quoted, which could cause parsing anomolies. Any field maked as type JSON will default to this mode.
  • Loading branch information...
commit 9b289c656c7763435dfdb4aa2caf9aa9da2059f0 1 parent e50952d
@adamkaplan authored
Showing with 13 additions and 0 deletions.
  1. +10 −0 app.js
  2. +3 −0  views/api.jade
View
10 app.js
@@ -272,6 +272,7 @@ function processRequest(req, res, next) {
var reqQuery = req.body,
params = reqQuery.params || {},
+ jsonParams = reqQuery.jsonParams || {},
methodURL = reqQuery.methodUri,
httpMethod = reqQuery.httpMethod,
dataFormat = reqQuery.dataFormat,
@@ -299,6 +300,15 @@ function processRequest(req, res, next) {
}
}
+ // Extract any parameters that are marked as JSON since they will otherwise be quoted
+ for (var jsonparam in jsonParams) {
+ if (jsonParams.hasOwnProperty(jsonparam) && params.hasOwnProperty(jsonparam)) {
+ if (jsonParams[jsonparam]) {
+ params[jsonparam] = JSON.parse(params[jsonparam])
+ }
+ }
+ }
+
var baseHostInfo = apiConfig.baseURL.split(':');
var baseHostUrl = baseHostInfo[0],
baseHostPort = (baseHostInfo.length > 1) ? baseHostInfo[1] : "";
View
3  views/api.jade
@@ -118,6 +118,9 @@ ul
option(value=choice, selected=true) #{choice}
- else
option(value=choice) #{choice}
+ - if (parameter.Type == 'JSON')
+ input(name='jsonParams[' + parameter.Name + ']', type='hidden', value=1)
+ input(name='params[' + parameter.Name + ']', value=parameter.Default, placeholder=className)
- else
input(name='params[' + parameter.Name + ']', value=parameter.Default, placeholder=className)
td.type=parameter.Type
Please sign in to comment.
Something went wrong with that request. Please try again.