Skip to content

Commit 17bb7d8

Browse files
committed
moving around things
1 parent 9a51f1e commit 17bb7d8

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

api/utils/common.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ common.decode_html = function(string) {
104104
return string;
105105
};
106106

107+
/**
108+
* Check if string is a valid json
109+
* @param {string} val - string that might be json encoded
110+
* @returns {object} with property data for parsed data and property valid to check if it was valid json encoded string or not
111+
**/
112+
function getJSON(val) {
113+
var ret = {valid: false};
114+
try {
115+
ret.data = JSON.parse(val);
116+
if (ret.data && typeof ret.data === "object") {
117+
ret.valid = true;
118+
}
119+
}
120+
catch (ex) {
121+
//silent error
122+
}
123+
return ret;
124+
}
125+
107126
/**
108127
* Escape special characters in the given value, may be nested object
109128
* @param {string} key - key of the value
@@ -155,19 +174,6 @@ function escape_html_entities(key, value, more) {
155174
return value;
156175
}
157176
common.getJSON = getJSON;
158-
function getJSON(val) {
159-
var ret = {valid: false};
160-
try {
161-
ret.data = JSON.parse(val);
162-
if (ret.data && typeof ret.data === "object") {
163-
ret.valid = true;
164-
}
165-
}
166-
catch (ex) {
167-
//silent error
168-
}
169-
return ret;
170-
}
171177

172178
common.log = logger;
173179

0 commit comments

Comments
 (0)