httparty


Can't convert String to integer or undefined method nil for []


Using Httparty, I get the following response
#parsed_reponse = > {"items" => {"#no" => "1", "#type" => "book", "#category" => "GENERAL" }}
when i use the following code to access #no, I am getting the
following error: "Can't convert String into Integer"
r = #response.parsed_response["items"]["#no"]
Can anyone help on this? I do get "Can't convert String into Integer"
or "Undefined method `[]' for nil:NilClass (NoMethodError)"
Can anyone explain this with an example?
I am no HTTParty expert but here is an example of what I do to iterate through all the data in a response:
class Items
include HTTParty
default_params :output => 'xml'
format :xml
base_uri '<base_uri>'
end
xml = Items.get('<xmlFile>')
xml["items"].each do |item|
puts Integer(item['#no'])
end

Related Links

HTTParty force_encoding: encode_with_ruby_encoding
Using plus signs in query strings with HTTParty
Can't convert String to integer or undefined method nil for []
HTTparty in Rhodes

Categories

HOME
sonarqube
notepad++
ng-idle
amp-html
android-studio-2.2
phpmyadmin
mysql-workbench
camera
mstest
solaris
package
owl-carousel
seo
static-site
rds
square
webix
mautic
filechannel
qsqlquery
bitnami
undertow
easeljs
tiki-wiki
gpio
angularjs-components
oculus
soot
bioinformatics
custom-controls
userdefaults
jmockit
quickfixj
git-squash
yowsup
processwire
fiware-cygnus
android-augmented-reality
amazon-ses
connection-pool
recurrent-neural-network
gdata
hackintosh
signals-slots
doc
skylink
claims
apollostack
android-checkbox
snapchat
double-click
dynamic-linq
proget
dotnet-httpclient
hammer.js
dbcontext
datamaps
mongotemplate
singleinstance
arq
flac
d3-force-directed
builtins
redistributable
microstation
async.js
dup
php-socket
aurora
findfirst
grass
httpruntime.cache
concept-insights
dllimport
wiredep
binomial-theorem
pax-exam
cgi-bin
baasbox
ansi
node-serialport
user-permissions
filesplitting
crowd
iso-prolog
mobility
mintty
live555
tinyxml
dct
android-framework
twitter-bootstrap-rails
menubar
qscrollarea
scriptaculous
c++builder-xe5
mbunit
pagedown
onload-event
intersect
extreme-programming
jdb
cgimage
jquery-tools
codebase
photolibrary
commerceserver2007
hbm2java
feasibility
int64

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App