6 Replies Latest reply on Sep 25, 2013 4:27 AM by GoMory ChAKhter

    How to load data from a json file to rhomobile model



      I am newbie in RhoMobile, i need to develop a simple inventory for product for exemple .


      I created a RhoMobile app with the model "ProductCatalog".

      To seed our initial database of products under the ProductCatalog, we will have a JSON file''Products.txt" with sample data .

      my goal is to load data from json file "Product.txt", for that I used the following code:

      #Seed the database with initial data

      catalog = ProductCatalog.find(:all) 

      if catalog.empty?

        fileName = File.join(Rho::RhoApplication::get_base_app_path(), '/public/Products.txt')

        lines = File.read(fileName)

        jsonContent = Rho::JSON.parse(lines)

        jsonContent.each {


        ProductCatalog.create("SKU" => json['SKU'], "Name" => json['Name'], "Image" => json['Image'])


        #finished creating database for real application you may

        # want to display a loading page to indicate to the user

        # something is going on


        #The catalog has been loaded already there is nothing to do


      My problem is that when I add a new row of data in "Products.txt" I can not load a new data in my application.



      Can you help me?