[My apologies for terse post earlier, as I spotted your question just as we were sitting down to lunch]
The other thing to watch for making JSON is the ‘trailing comma’ bug. Formally, JSON does not allow this:
[{
"id": 12345,
text": "foo"
},
{
"id": 12345,
text": "bar"
}, // <- trailing comma
]
Realising that loop-based output is liable to create the latter, many JSON based processes simply allow for the mistake. Others don’t, q.v. fuse.js
fuzzy search—as trialled here. The search uses the whole of aTbref content exported as JSON data. I had all sorts of problems until @jackbaty kindly reported I’d left a hanging comma in my JSON that gave a silent [sic] fail in fuse.js.
I think the issue with attributeCode() in this context is the line breaks in $Text were not being turned into the \n
suitable for JavaScript-based JSON, same for tabs, etc.
I’ve recently had cause (requests from users of the data) to export several large projects to JOSN. Luckily, they called for a flat JSON file with no nested objects, though Tinderbox can do that too: the current aTbRef TBX zip includes templates that show how I made the JSON for the new search feature. But, note that if exporting your Tinderbox outline as nested JSON objects you’ve a lot of ‘hanging commas’ to avoid (nor is this something the app can necessarily guess for you—you need to add ^export^ based checks accordingly).