I have a Rhodes (RhoMobile) PropertyBag Model that I would like to convert to JSON string. I tried @model_instance.to_json but it does not appear that method exists. I would like to then take the JSON string and submit it to a RESTful service. Any assistance is much appreciated. Thank you.
Convert a Rhodes PropertyBag Model to JSON
402 views Asked by Amir Khawaja At
2
There are 2 answers
1
On
I think first of all you need to convert the model to meta data, Meta data is defined in a source adapter by implementing an adapter method metadata
that returns a JSON structure. then you can use yourmodelname.metadata('foo' => 'bar' }.to_json
then it will convert your database into json. This is basically done with FixedSchema, not sure about the PropertyBag.
I feel so silly. I did not realize the json gem is not automatically included. All I had to do was require 'json' at the top of the controller file and call @model_name.to_json. I hope this helps someone else.