Modifying a property containing JSON breaks the JSON
It looks like when using the Ember Inspector to modify a property containing stringified JSON, it will wrap an extra set of quotes around said JSON. This then breaks JSON.parse, since it is now an invalid format.
I have a model with a config property with a default value of:
[{"caption":"test"}]
In the controller, I just have a little debug routine that console logs the value of this property when it changes:
debug: function () {
console.log(this.get('config'));
}.property('config')
On the initial page load, it outputs the correct text:
[{"caption":"test"}]
But when I edit this JSON with the Ember Inspector, then an extra set of quotes appears around the value.
I change it to:
[{"caption":"testing"}]
And the console outputs:
"[{"caption":"testing"}]"
// instead of:
[{"caption":"testing"}]
The inspector converts the value to string when the Json is invalid.
What is really strange is that arrays are not supposed to be editable, so your ability to edit [{"caption":"testing"}] is really strange. I would double check it's not a string in the first place...
As for [{"caption":"testing"}], it is valid Json, so it's not supposed to be converted into a string. Unless it is without the quotes [{caption:"testing"}], which is invalid Json and will convert it into a string.
As you can see in the code check the code, the value goes through JSON.parse and if it fails, the value is assumed to be a string.
It is stringified JSON, not an array. From Ember-Inspector's point of view, it's just a string.
I meant [{"caption":"test"}] should not be editable in the inspector.
Did you try editing it into valid json (with double quotes on properties) ?
It is editable in the inspector, because it's not an array.
Here are some screenshots--
-
The original value:

-
Selecting the value to edit it:

-
After I press 'Enter' after changing "test1" to "testing":

As seen in the third image, the value gets wrapped around some quotes, and those quotes now become part of the value itself. In my code, this property is fed to JSON.parse when it changes, but since those extra quotes get added, it is no longer valid JSON and it throws an error.
Ah, I understand now thanks :)
Will look into it.
Thanks for reporting! You can make sure the issue is fixed by using the current master branch.