I was looking through the source hoping that perhaps the layer SID was causing the problem, but that doesn't seem to be the case. Can I partially set from JSON? If I remove a few elements from the JSON, can I still load from JSON and keep the other values as they are when the Item is created? I also noticed that the issue is independant of whether layouts are changed.
Should I give up and go to some kind of abstract Inventory system? I'm hesitant to do that, since Construct 2 doesn't really handle abstract objects very well: You can't put them in data structures. It seems much more complicated to hang custom events on an array inventory....
Edit: here is the JSON, after the "l" element was removed.
{"c2":true,"ivs":{"4983201361434822":"2d12"},"w":{"x":40,"y":214.20833333333331,"w":24,"h":24,"zi":16},"behs":{"2355029582157182":{"SlotUID":611},"3459439661079695":{"enabled":true},"8791895563351892":{"dx":0,"dy":0,"cancelStep":0,"enabled":true,"stepMode":0,"pxPerStep":5}},"data":{"a":9827539049161972,"f":12,"cas":0,"fs":0,"ar":0,"at":0}}[/code:3991b27o]
More Edit: Using firebug, I was able to catch [code:3991b27o]SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
http://localhost:50000/commonace.js
Line 609[/code:3991b27o] I'm going to look into why this instance is being passed an empty string. I've attached a screenie of the test event I created. I'd be inclined to leave a capx, but I am using a bunch of 3rd party behaviors.
In this screenshot, Save Item and Create Instance are both functions from a little custom behavior I made which is able to save the object type of an unknown sprite, and respawn it from sid. It seems to work correctly. If I remove the Set From JSON line, it seems to properly creates a MeleeWeapon or FryingPan or Boots or whatever. I can upload that behavior if someone is interested.
Edit: caught a major derp in the above screenshot. ItemJSON is now properly set to Item.asJSON, and everything works, at least in this test case without changing layouts. This is the same as my test case. I notice that it does NOT work if I strip out the layer sid, so that must be important somehow. It's also the only data in that JSON that seems like it might be mismatched. Should I create a JSON mangler to replace the layer sid with the sid of the new "UI" layer?
To confirm: I have my main project behaving the same way as this demo, which is able to save and restore sprites from JSON, but it just destroys the sprite whenever I try to SetFromJSON on a different layout from the one where the JSON was created. Help!