Running firefox addon fails with Syntax Error when JSON is escaped in package.json -
i'm making firefox addon (sdk/jetpack), , using simple-prefs module. want have array in 1 of preferences, in package.json have written as
{ [...] "preferences":[ [...] { "name":"audio-priority", "title":"audio priority", "type":"string", "value":"[\"audio-notifications\",\"audio-error\",\"audio-messages\",\"audio-youtube\",\"audio-twitch\"]", "hidden":true }, [...] } but when run it, builds , browser opens, in console comes with
console.error: ltt-notifier: message: syntaxerror: missing ) after argument list stack: evaluate@resource://gre/modules/xpiprovider.jsm -> jar:file:///tmp/tmpn5quoo.mozrunner/extensions/jid1-23jjnbcwpfq3ag@jetpack.xpi!/bootstrap.js -> resource://gre/modules/commonjs/toolkit/loader.js:223 setdefaultprefs@resource://gre/modules/xpiprovider.jsm -> jar:file:///tmp/tmpn5quoo.mozrunner/extensions/jid1-23jjnbcwpfq3ag@jetpack.xpi!/bootstrap.js -> resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/addon/runner.js:66 and whole load more stuff afterwards (stack), , addon not running. if change array not have \" (or escaped characters - tried using \u0022 instead) in, works fine, makes me think mozilla bug, fault.
based on links https://bugzilla.mozilla.org/show_bug.cgi?id=501156 (which links https://groups.yahoo.com/neo/groups/json/conversations/topics/1286 ) have figured out answer should be
"[\\\"audio-notifications\\\",\\\"audio-error\\\",\\\"audio-messages\\\",\\\"audio-youtube\\\",\\\"audio-twitch\\\"]", because first time json decoded unescapes \" ", json requires still \". escaping \ ", first time parsed, when entire file gets processed, turns into
[\"audio-notifications\",\"audio-error\",\"audio-messages\",\"audio-youtube\",\"audio-twitch\"] which no longer closes quotes (which presume issue because error related evaluate command in native code), , means still valid json when comes decoded.
Comments
Post a Comment