Reverse Engineering

Our web app using GOJS NodeDataarray to create icons. This is working fine. Our old app has similar features and wants to migrate to data. How I can create model data in C# so that model.FromJson can read it.

That might be fairly straight-forward to implement. Certainly writing out JSON is easy enough, and the format that it accepts is pretty simple, as you have seen in many of the samples that show it below the diagram in a <textarea>. I guess it depends on the schema that your current database is using. I can’t give you any particulars because it really depends on your current storage schema.

Model.outjosn generated below;
{ “class”: “go.GraphLinksModel”, “nodeDataArray”: [ {“key”:“ctr:72”, “name”:“P9.191”, “id”:“72”, “geo”:"$controller", “size”:“25 25”, “item”:“Controller”, “color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}, “loc”:“620 480”}, {“key”:“dvc:11431”, “id”:“11431”, “geo”:"$reader", “size”:“25 25”, “item”:“Reader”, “color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}, “loc”:“1240 82”, “name”:“P9.191-R1”}, {“key”:“dvc:11432”, “id”:“11432”, “geo”:"$reader", “size”:“25 25”, “item”:“Reader”, “color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}, “loc”:“1240 277”, “name”:“P9.191-R2”}, {“key”:“ctr:73”, “name”:“P9.101”, “id”:“73”, “geo”:"$controller", “size”:“25 25”, “item”:“Controller”, “color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}, “loc”:“620 439.92216796875”}, {“key”:“dvc:11483”, “id”:“11483”, “geo”:"$reader", “size”:“25 25”, “item”:“Reader”, “color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}, “loc”:“1240 466”, “name”:“P9.101-R1”} ], “linkDataArray”: [ ]}
But when I want to generate using serialiseobject in c# not able to recognise. Hence I want to know how tojson is doing formatting?

I don’t know what to say. Generating some JSON-formatted text on the server isn’t something I can help with – it’s common knowledge. By looking at what Model.toJson produces, you can figure out what you need to generate so that Model.fromJson will work.

Or you can send whatever format/schema you want to the client and then build the GraphLinksModel programmatically there, totally bypassing any JSON representation.

I know what to do. But I am asking to know whether is there any alternative way to get the output. Anyway can you give me some tips how to bind data to model. For our model the below is same;
“color”:{“class”:“go.Brush”, “type”:“Linear”, “start”:{“class”:“go.Spot”, “x”:0.5, “y”:0, “offsetX”:0, “offsetY”:0}, “end”:
{“class”:“go.Spot”, “x”:0.5, “y”:1, “offsetX”:0, “offsetY”:0}, “colorStops”:{“0”:"#42C0FB", “1”:"#009ACD"}}

What are you asking for when you ask for “any alternative way to get the output”?

I think you already have templates that make use of that data.

In fact, I bet some of them use TwoWay Bindings when they didn’t need to and probably shouldn’t have. That’s what I conclude when I see the serialization of a Linear Gradient Brush. The binding could have used a simpler representation of the brush and constructed the desired linear gradient in the conversion function.