{"record":{"id":"eb583dd3243b5b6d","repo":"octobercms/october","slug":"broken-json-body-near-str","errorCode":null,"errorMessage":"Broken JSON body near ${str}","messagePattern":"Broken JSON body near (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/system/assets/js/framework-bundle.js","lineNumber":2327,"sourceCode":"              stack.push(\"[\");\n            } else if (str[i] === \"]\") {\n              if (stack[stack.length - 1] === \"[\") {\n                stack.pop();\n              } else {\n                throw new Error(\"Broken JSON \" + (str[pos] === \"{\" ? \"object\" : \"array\") + \" body near \" + body);\n              }\n            }\n          }\n          if (!stack.length) {\n            return {\n              originLength: i - pos,\n              body\n            };\n          }\n        }\n        throw new Error(\"Broken JSON \" + (str[pos] === \"{\" ? \"object\" : \"array\") + \" body near \" + body);\n      }\n      throw new Error(\"Broken JSON body near \" + str.substr(pos - 5 >= 0 ? pos - 5 : 0, 50));\n    }\n    canBeKeyHead(ch) {\n      if (ch[0] === \"\\\\\") return false;\n      if (ch[0] >= \"a\" && ch[0] <= \"z\" || ch[0] >= \"A\" && ch[0] <= \"Z\" || ch[0] === \"_\") return true;\n      if (ch[0] >= \"0\" && ch[0] <= \"9\") return true;\n      if (ch[0] === \"$\") return true;\n      if (ch.charCodeAt(0) > 255) return true;\n      return false;\n    }\n    isBlankChar(ch) {\n      return ch === \" \" || ch === \"\\n\" || ch === \"\t\";\n    }\n  };\n\n  // ../../vendor/larajax/larajax/resources/src/core/request-builder.js\n  var RequestBuilder = class _RequestBuilder {\n    constructor(element, handler, options) {\n      this.options = options || {};","sourceCodeStart":2309,"sourceCodeEnd":2345,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/assets/js/framework-bundle.js#L2309-L2345","documentation":"The fallback throw at the bottom of JsonParser.getBody in October CMS's AJAX framework: the character at the value position cannot begin any JSON value this parser knows (not a quote, not t/f/n keyword start, not a number character, not '{' or '['). The message echoes up to 50 characters starting 5 bytes before the failure point to give context.","triggerScenarios":"A value position starting with ',', ':', ')', '}' via a bare position, or any letter other than t/f/n - e.g. oc.parseJSON(\"{a: ,b: 1}\") (empty value before comma) or data-request-data=\"{fn: x}\") where x is an unquoted word that is not true/false/null.","commonSituations":"Empty value left between commas ({a: ,b: 1}); unquoted identifiers as values (must be quoted); a variable placeholder like {tpl: %s} not substituted; stray punctuation pasted into the attribute.","solutions":["Give the value a legal form: quote words ({fn: 'x'}), use true/false/null, a number, or {..}/[..]","Remove empty value slots ({a: ,b: 1} -> {b: 1})","Pre-parse the attribute with oc.parseJSON during development to catch illegal value starts before the request fires"],"exampleFix":"<!-- before -->\n<div data-request-data=\"{fn: x, a: ,b: 1}\">...</div>\n\n<!-- after -->\n<div data-request-data=\"{fn: 'x', b: 1}\">...</div>","handlingStrategy":"validation","validationCode":"function valuesStartLegally(s) {\n  // every value position (after ':' or ',' or '[' ) must start with a legal token\n  return !/[:,\\[]\\s*([^\\s\\-+.\\d\\{\"'tfn\\]}].*)?$/.test(s);\n}","typeGuard":null,"tryCatchPattern":"try { oc.request(el, 'onGo'); } catch (e) { if (/Broken JSON body near/.test(e.message)) console.error('Illegal value start:', e.message); }","preventionTips":["Quote any word used as a value; only true/false/null may stay bare","Delete empty value slots ({a: ,b: 1}) instead of leaving them","Substitute template placeholders before the value reaches the DOM"],"tags":["json","ajax","html-attribute","parser","syntax"],"backgroundTag":"invalid-json-attribute","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}