Can not save a json string

I have a json string like below

‘{“id”:null,“name”:null,“count”:26,“nodes”:[{“id”:“node_1”,“name”:“node_1”,“type”:“start”,“shape”:“oval”,“number”:1,“left”:100,“top”:80,“width”:20,“height”:20,“property”:null},{“id”:“node_2”,“name”:“node_2”,“type”:“end”,“shape”:“oval”,“number”:2,“left”:753,“top”:462,“width”:20,“height”:20,“property”:null},{“id”:“node_3”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:3,“left”:195,“top”:69,“width”:100,“height”:40,“property”:{“role”:1,“description”:“test”}},{“id”:“node_4”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:4,“left”:196,“top”:141,“width”:100,“height”:40,“property”:{“role”:2,“description”:“test”}},{“id”:“node_5”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:5,“left”:197,“top”:210,“width”:100,“height”:40,“property”:{“role”:3,“description”:“test”}},{“id”:“node_6”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:6,“left”:197,“top”:280,“width”:100,“height”:40,“property”:{“role”:4,“description”:“test”}},{“id”:“node_11”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:11,“left”:260,“top”:453,“width”:100,“height”:40,“property”:{“role”:9,“description”:“test”}},{“id”:“node_14”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:14,“left”:427,“top”:67,“width”:100,“height”:40,“property”:{“role”:5,“description”:“test”}},{“id”:“node_15”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:15,“left”:427,“top”:139,“width”:100,“height”:40,“property”:{“role”:6,“description”:“test”}},{“id”:“node_19”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:19,“left”:426,“top”:216,“width”:100,“height”:40,“property”:{“role”:7,“description”:“test”}},{“id”:“node_20”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:20,“left”:429,“top”:308,“width”:100,“height”:40,“property”:{“role”:8,“description”:“test”}},{“id”:“node_24”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:24,“left”:489,“top”:449,“width”:100,“height”:40,“property”:{“role”:10,“description”:“test”}}],“lines”:[{“id”:“line_7”,“name”:“line_7”,“type”:“line”,“shape”:“line”,“number”:7,“from”:“node_1”,“to”:“node_3”,“fromx”:120,“fromy”:90,“tox”:195,“toy”:89,“polydot”:[],“property”:null},{“id”:“line_8”,“name”:“line_8”,“type”:“line”,“shape”:“line”,“number”:8,“from”:“node_3”,“to”:“node_4”,“fromx”:245,“fromy”:109,“tox”:246,“toy”:141,“polydot”:[],“property”:null},{“id”:“line_9”,“name”:“line_9”,“type”:“line”,“shape”:“line”,“number”:9,“from”:“node_4”,“to”:“node_5”,“fromx”:246,“fromy”:181,“tox”:247,“toy”:210,“polydot”:[],“property”:null},{“id”:“line_10”,“name”:“line_10”,“type”:“line”,“shape”:“line”,“number”:10,“from”:“node_5”,“to”:“node_6”,“fromx”:247,“fromy”:250,“tox”:247,“toy”:280,“polydot”:[],“property”:null},{“id”:“line_12”,“name”:“line_12”,“type”:“line”,“shape”:“line”,“number”:12,“from”:“node_6”,“to”:“node_11”,“fromx”:247,“fromy”:320,“tox”:260,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_16”,“name”:“line_16”,“type”:“line”,“shape”:“line”,“number”:16,“from”:“node_6”,“to”:“node_14”,“fromx”:297,“fromy”:280,“tox”:427,“toy”:107,“polydot”:[],“property”:null},{“id”:“line_17”,“name”:“line_17”,“type”:“line”,“shape”:“line”,“number”:17,“from”:“node_14”,“to”:“node_15”,“fromx”:477,“fromy”:107,“tox”:477,“toy”:139,“polydot”:[],“property”:null},{“id”:“line_18”,“name”:“line_18”,“type”:“line”,“shape”:“line”,“number”:18,“from”:“node_15”,“to”:“node_11”,“fromx”:427,“fromy”:179,“tox”:360,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_21”,“name”:“line_21”,“type”:“line”,“shape”:“line”,“number”:21,“from”:“node_15”,“to”:“node_19”,“fromx”:477,“fromy”:179,“tox”:476,“toy”:216,“polydot”:[],“property”:null},{“id”:“line_22”,“name”:“line_22”,“type”:“line”,“shape”:“line”,“number”:22,“from”:“node_19”,“to”:“node_20”,“fromx”:476,“fromy”:256,“tox”:479,“toy”:308,“polydot”:[],“property”:null},{“id”:“line_23”,“name”:“line_23”,“type”:“line”,“shape”:“line”,“number”:23,“from”:“node_20”,“to”:“node_11”,“fromx”:429,“fromy”:348,“tox”:360,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_25”,“name”:“line_25”,“type”:“line”,“shape”:“line”,“number”:25,“from”:“node_11”,“to”:“node_24”,“fromx”:360,“fromy”:473,“tox”:489,“toy”:469,“polydot”:[],“property”:null},{“id”:“line_26”,“name”:“line_26”,“type”:“line”,“shape”:“line”,“number”:26,“from”:“node_24”,“to”:“node_2”,“fromx”:589,“fromy”:469,“tox”:753,“toy”:472,“polydot”:[],“property”:null}]}’

I save it in a text field, when I read it from databace, it become
unreadable code.

I test it by the code below:

f=Flow.find(1)
f=‘json string above’
f.save!
p f.jsonstring

it’s right,but if I read it again from database, it become unreadable
code.
f=Flow.find(1)
f=‘json string above’
f.save!
f=Flow.find(1)
p f.jsonstring

Anyone can help me?

Michael G. wrote:

I have a json string like below

‘{“id”:null,“name”:null,“count”:26,“nodes”:[{“id”:“node_1”,“name”:“node_1”,“type”:“start”,“shape”:“oval”,“number”:1,“left”:100,“top”:80,“width”:20,“height”:20,“property”:null},{“id”:“node_2”,“name”:“node_2”,“type”:“end”,“shape”:“oval”,“number”:2,“left”:753,“top”:462,“width”:20,“height”:20,“property”:null},{“id”:“node_3”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:3,“left”:195,“top”:69,“width”:100,“height”:40,“property”:{“role”:1,“description”:“test”}},{“id”:“node_4”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:4,“left”:196,“top”:141,“width”:100,“height”:40,“property”:{“role”:2,“description”:“test”}},{“id”:“node_5”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:5,“left”:197,“top”:210,“width”:100,“height”:40,“property”:{“role”:3,“description”:“test”}},{“id”:“node_6”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:6,“left”:197,“top”:280,“width”:100,“height”:40,“property”:{“role”:4,“description”:“test”}},{“id”:“node_11”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:11,“left”:260,“top”:453,“width”:100,“height”:40,“property”:{“role”:9,“description”:“test”}},{“id”:“node_14”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:14,“left”:427,“top”:67,“width”:100,“height”:40,“property”:{“role”:5,“description”:“test”}},{“id”:“node_15”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:15,“left”:427,“top”:139,“width”:100,“height”:40,“property”:{“role”:6,“description”:“test”}},{“id”:“node_19”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:19,“left”:426,“top”:216,“width”:100,“height”:40,“property”:{“role”:7,“description”:“test”}},{“id”:“node_20”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:20,“left”:429,“top”:308,“width”:100,“height”:40,“property”:{“role”:8,“description”:“test”}},{“id”:“node_24”,“name”:“test”,“type”:“node”,“shape”:“rect”,“number”:24,“left”:489,“top”:449,“width”:100,“height”:40,“property”:{“role”:10,“description”:“test”}}],“lines”:[{“id”:“line_7”,“name”:“line_7”,“type”:“line”,“shape”:“line”,“number”:7,“from”:“node_1”,“to”:“node_3”,“fromx”:120,“fromy”:90,“tox”:195,“toy”:89,“polydot”:[],“property”:null},{“id”:“line_8”,“name”:“line_8”,“type”:“line”,“shape”:“line”,“number”:8,“from”:“node_3”,“to”:“node_4”,“fromx”:245,“fromy”:109,“tox”:246,“toy”:141,“polydot”:[],“property”:null},{“id”:“line_9”,“name”:“line_9”,“type”:“line”,“shape”:“line”,“number”:9,“from”:“node_4”,“to”:“node_5”,“fromx”:246,“fromy”:181,“tox”:247,“toy”:210,“polydot”:[],“property”:null},{“id”:“line_10”,“name”:“line_10”,“type”:“line”,“shape”:“line”,“number”:10,“from”:“node_5”,“to”:“node_6”,“fromx”:247,“fromy”:250,“tox”:247,“toy”:280,“polydot”:[],“property”:null},{“id”:“line_12”,“name”:“line_12”,“type”:“line”,“shape”:“line”,“number”:12,“from”:“node_6”,“to”:“node_11”,“fromx”:247,“fromy”:320,“tox”:260,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_16”,“name”:“line_16”,“type”:“line”,“shape”:“line”,“number”:16,“from”:“node_6”,“to”:“node_14”,“fromx”:297,“fromy”:280,“tox”:427,“toy”:107,“polydot”:[],“property”:null},{“id”:“line_17”,“name”:“line_17”,“type”:“line”,“shape”:“line”,“number”:17,“from”:“node_14”,“to”:“node_15”,“fromx”:477,“fromy”:107,“tox”:477,“toy”:139,“polydot”:[],“property”:null},{“id”:“line_18”,“name”:“line_18”,“type”:“line”,“shape”:“line”,“number”:18,“from”:“node_15”,“to”:“node_11”,“fromx”:427,“fromy”:179,“tox”:360,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_21”,“name”:“line_21”,“type”:“line”,“shape”:“line”,“number”:21,“from”:“node_15”,“to”:“node_19”,“fromx”:477,“fromy”:179,“tox”:476,“toy”:216,“polydot”:[],“property”:null},{“id”:“line_22”,“name”:“line_22”,“type”:“line”,“shape”:“line”,“number”:22,“from”:“node_19”,“to”:“node_20”,“fromx”:476,“fromy”:256,“tox”:479,“toy”:308,“polydot”:[],“property”:null},{“id”:“line_23”,“name”:“line_23”,“type”:“line”,“shape”:“line”,“number”:23,“from”:“node_20”,“to”:“node_11”,“fromx”:429,“fromy”:348,“tox”:360,“toy”:453,“polydot”:[],“property”:null},{“id”:“line_25”,“name”:“line_25”,“type”:“line”,“shape”:“line”,“number”:25,“from”:“node_11”,“to”:“node_24”,“fromx”:360,“fromy”:473,“tox”:489,“toy”:469,“polydot”:[],“property”:null},{“id”:“line_26”,“name”:“line_26”,“type”:“line”,“shape”:“line”,“number”:26,“from”:“node_24”,“to”:“node_2”,“fromx”:589,“fromy”:469,“tox”:753,“toy”:472,“polydot”:[],“property”:null}]}’

I save it in a text field, when I read it from databace, it become
unreadable code.

I test it by the code below:

f=Flow.find(1)
f=‘json string above’
f.save!
p f.jsonstring

it’s right,but if I read it again from database, it become unreadable
code.
f=Flow.find(1)
f=‘json string above’
f.save!
f=Flow.find(1)
p f.jsonstring

Anyone can help me?

Ok, I got it. In the database, the field type is varchar[MAX], I change
the field type to text, it work.
Here is another question. I user the ror+sqlserver, and I create the
field use :text key. Why it will become varchar[MAX], or which key can I
use next if I want to create text field

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs