DavidDurman / FlexiJsonEditor

JSON editor jQuery plugin
http://jsonmate.com
Other
560 stars 139 forks source link

JsObject usually contain functions. #11

Closed malaikuangren closed 11 years ago

malaikuangren commented 11 years ago

Hi, David, firstly I would like to thanks your owesome plugin, I found a issue. please review it . If the jsobject contains the function , the jsoneditor will show them in the tree. how to ignore the function in the editor? thanks.

DavidDurman commented 11 years ago

Thanks! Could you please provide an example? I cannot reproduce this issue. And it actually quite surprises me as the jsoneditor internally calls JSON.stringify() to get property values. Therefore, functions should be stripped down. You can also see this happening in http://jsonmate.com which uses this plugin.

malaikuangren commented 11 years ago

Hi , David , here is what I did. please review it .

var sContent=singletonTemplate.toJsonString(); $('#editor').jsonEditor(singletonTemplate, { change: function() { $('#json').html(sContent); } });

singletonTemplate is a js object which contains the toJsonString() function.(did you notice the first parameter is jsobject?) and toJsonString() just return JSON.stringify(this); so I believe this result definitely without function string output. below is a screenshot . you can see there is a toJsonString in there . please review it .thanks

jsoneditor

DavidDurman commented 11 years ago

Yes, and that's correct. Function is not a valid JSON data type, see http://en.wikipedia.org/wiki/JSON.

malaikuangren commented 11 years ago

My question is can I remove them from editor. thanks.

DavidDurman commented 11 years ago

Fixed in ec9fab50bb959afc6b5c464f0c769607fc44c73a.

malaikuangren commented 11 years ago

Thanks you work. It is very nice of you.