diff --git a/core/modules/filters/json-ops.js b/core/modules/filters/json-ops.js index 75a34e94a..0c58964eb 100644 --- a/core/modules/filters/json-ops.js +++ b/core/modules/filters/json-ops.js @@ -273,7 +273,10 @@ function setDataItem(data,indexes,value) { lastIndex = $tw.utils.parseInt(lastIndex); if(lastIndex < 0) { lastIndex = lastIndex + current.length }; } - current[lastIndex] = value; + // Only set indexes on objects and arrays + if(typeof current === "object") { + current[lastIndex] = value; + } return data; } diff --git a/editions/test/tiddlers/tests/test-json-filters.js b/editions/test/tiddlers/tests/test-json-filters.js index a8903970a..bfb8a4504 100644 --- a/editions/test/tiddlers/tests/test-json-filters.js +++ b/editions/test/tiddlers/tests/test-json-filters.js @@ -124,6 +124,7 @@ describe("json filter tests", function() { }); it("should support the jsonset operator", function() { + expect(wiki.filterTiddlers("[jsonset[a],[aa]]")).toEqual(['"First"','"Second"','"Third"']); expect(wiki.filterTiddlers("[{First}jsonset[]]")).toEqual(['{"a":"one","b":"","c":1.618,"d":{"e":"four","f":["five","six",true,false,null]}}']); expect(wiki.filterTiddlers("[{First}jsonset[],[Antelope]]")).toEqual(['"Antelope"']); expect(wiki.filterTiddlers("[{First}jsonset:number[],[not a number]]")).toEqual(['0']);