Tag: json

how to make api call to fetch json data from a url

i am trying to fetch a json data in my rails app from a url. how to make this api call. { “name”: “MagicList”, “count”: 20, “frequency”: “realtime”, “version”: 5, “newdata”: true, “lastrunstatus”: “success”, “lastsuccess”: “Sat Apr 26 2014 14:34:40 GMT+0000 (UTC)”, “results”: { “collection1”: [ { “Title”: { “href”: “http://www.magicbricks.com/propertyDetails/2-BHK-746-Sq-ft-Multistorey-Apartment-FOR-Sale-Sector-79-in-Gurgaon&id=C0gt4k2Fa9tzpSvf+uAgZw==”, “text”: “2 BHK Multistorey […]

how to parse and display hstore key/value in rails

I’ved got a data type that is postgres hstore that stores a json string. I want to be able to parse and display the key/values on rails html page. Somehow, I just do not know how to run a parse on the data field and display each one of key/value listed in the string. <% […]

ActionView::Template::Error: No such file or directory @ unlink_internal – C:/Users/Javi/AppData/Local/Temp/execjs201504 29-7844-j0j83vjson

When I run my tests, the controller one fails claiming that it can’t find any views/categories/new.html.erb file. This is the failure: $ rake test:controllers DL is deprecated, please use Fiddle Run options: –seed 30439 # Running: E Finished in 2.486100s, 0.4022 runs/s, 0.0000 assertions/s. 1) Error: CategoriesControllerTest#test_new: ActionView::Template::Error: No such file or directory @ unlink_internal […]

How do I combine this Hash to a single JSON object?

I’m using the following code to generate a JSON file containing all category information for a particular website. The goal is to have a JSON file with the following format: [ { “id”:”36_17″, “name”:”Diversen Particulier”, “group”:”Diversen”, “search_attributes”:{ “0”:”Prijs van/tot”, “1”:”Groep en Rubriek”, “2”:”Conditie”, } }, { “id”:”36_18″, “name”:”Diversen Zakelijk”, “group”:”Diversen”, “search_attributes”:{ “0”:”Prijs van/tot”, “1”:”Groep en […]

Why is installing the json 1.8.6 gem on Windows 8 not working?

I’ve cloned down a Rails app and am trying to install all the gems on my PC. I’m running Windows 8.1 x64, and I’ve installed the x64 devkit at C:/devkit and am using uru to manage ruby versions so that I can use ruby 2.3.1. When I run bundle install or gem install json -v […]

Json creation in ruby for a list

I am new to Ruby. I want to create a JSON file for a group of elements. For this, I am using eachfunction to retrieve the datas. I want to create json as follows for the 4 length array, ‘{ “desc”:{ “1”:”1st Value”, “2”:”2nd value” “3”:”3rd Value”, “4”:”4th value” }, }’ This is my array […]

Convert csv to json in ruby

CSV id,modifier1_name,modifier2_price,modifier2_name,modifier2_price,modifier2_status 1,’Small’,10,’Large’,20,’YYY’ 2,’Small’,20,’Large’,30,’YYY’ JSON [ { id: 1, modifier: [ {name: ‘Small’, price: 10}, {name: ‘Large’, price: 20, status: ‘YYY’}] }, { id: 2, modifier: [ {name: ‘Small’, price: 20}, {name: ‘Large’, price: 30, status: ‘YYY’}], } ] How to convert CSV to Json in this case when modifiers can be different ?

Rspec checking for json response

I am trying to create a mock object and i am checking whether my method receives the right param and expected result. Below is my spec. require ‘spec_helper’ describe User do let(:username) {“test@test.com”} let(:password) {“123”} let(:code) {“0”} context “when signing in” do it “should sign in” do user = double(“user”) expected_results = { “token”: “123” […]

return json from ruby using rack

i’m still fairly new to server side scripts and try myself a little bit on ruby to write me little helpers and to learn some new things. I currently try to write a small ruby app which sends a json file of all images within a specific folder to my page where i can use […]

Is there any way the JSON comparison ignores the whole section misplaced?

I am trying to compare two JSON objects. When a ‘key:value’ pair order changes, I can use JSON.parse, and during comparison, the test passes like this: doc1 = ‘{ “KayA”: “Value_A”, “KeyB”: “value_B” }’ doc2 = ‘{ “KeyB”: “value_B”, “KayA”: “Value_A” }’ doc1 = JSON.parse(doc1) doc2 = JSON.parse(doc2) expect(doc1).to eq(doc2) # true But when the […]

Ruby is the best programming language in the world - Ruby on Rails.