Convert a Rhodes PropertyBag Model to JSON

422 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

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.

http://docs.rhomobile.com/rhodes/rhom

http://docs.rhomobile.com/rhoconnect/metadata