diff --git a/index.js b/index.js index 283aaa8..23ac2bf 100644 --- a/index.js +++ b/index.js @@ -323,17 +323,22 @@ function decodeString(str) { // look up json data if (str.charAt(++i)) { - try { - p.data = json.parse(str.substr(i)); - } catch(e){ - return error(); - } + p = tryParse(p, str.substr(i)); } debug('decoded %s as %j', str, p); return p; } +function tryParse(p, str) { + try { + p.data = json.parse(str); + } catch(e){ + return error(); + } + return p; +}; + /** * Deallocates a parser's resources *