0

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.

Amir Khawaja
  • 459
  • 1
  • 6
  • 13

2 Answers2

0

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

uday
  • 8,544
  • 4
  • 30
  • 54
0

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.

Amir Khawaja
  • 459
  • 1
  • 6
  • 13