Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic toJson Doesn't Save Id Parameter (Read 4064 times)
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
toJson Doesn't Save Id Parameter
Nov 18th, 2017 at 5:51pm
Print Post  
Portion of diagram object

c.ShapeNode
allowFlip:false
allowIncomingLinks:true
allowOutgoingLinks:true
anchorPattern:c.AnchorPattern {points: Array(3), regIndex: -1, serverRegistered: false}
anchorPointVisuals:[indexOf: ƒ, remove: ƒ, contains: ƒ, any: ƒ, all: ƒ, …]
bounds:mdraw.Rect {x: 30.862499999999997, y: 18.427083333333332, width: 24, height: 24, transform: M…n.D…g.Matrix, …}
brush:undefined
enabledHandles:511
expandable:false
expanded:true
flipX:false
flipY:false
font:null
graphicsContainer:mdraw.Container {x: 0, y: 0, content: Array(2), invalidParent: null, zIndex: 0, …}
handlesSize:undefined
handlesStyle:1
hyperLink:""
id:0     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


var tempJson = diagram.toJson()

running the above code on the diagram object produces the following output (just showing the relevant section).
The id which was 0 in the diagram object is now null in the JSON string.

"items":[{"__type":"MindFusion.Diagramming.ShapeNode","instanceId":0,"zIndex":0,
"tag":null,"id":null,"text":"Start",

Tried 3.0.1 and 3.2. Both failed to save the id.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: toJson Doesn't Save Id Parameter
Reply #1 - Nov 20th, 2017 at 6:25am
Print Post  
It seems it saves only truth-y values at this time and will skip 0. We'll add some handling for zeros in next few days. For time being you could adjust the loaded IDs after loading, like if (!item.id) item.id = 0;

Regards,
Slavcho
  
Back to top
 
IP Logged
 
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
Re: toJson Doesn't Save Id Parameter
Reply #2 - Nov 20th, 2017 at 11:23am
Print Post  
Is it possible to create my own object and save it in a node or somehow associate it with a node? If so are there limitations to the object I could use? That would be a work around for me if it can be done.

Looks like setTag, getTag might do what I want?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: toJson Doesn't Save Id Parameter
Reply #3 - Nov 20th, 2017 at 12:15pm
Print Post  
Any JS object literal should work for Id or Tag - the control will just pass it to browser's JSON.stringify and JSON.parse methods for serialization. If using XML serialization, you'd need to handle serializeTag and deserializeTag events instead.
  
Back to top
 
IP Logged
 
alukes
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 61
Joined: Jul 1st, 2011
Re: toJson Doesn't Save Id Parameter
Reply #4 - Nov 21st, 2017 at 5:36am
Print Post  
I am able to store and retrieve my object using get and set tag, so I am good for now. I don't need Id to work.

Thanks
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: toJson Doesn't Save Id Parameter
Reply #5 - Nov 25th, 2017 at 7:51am
Print Post  
This should correctly save 0 as id -
https://mindfusion.eu/_temp/jsdiag_id.zip

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint