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
localization
paraview
webdriver
datastore
angular2-material
numbers
requirements
spring-data-redis
soa
aws-cli
big-o
nested-if
pearson-correlation
tvos
nstableheaderview
joomla3.0
32bit-64bit
owin
reactive-programming
text-mining
filechannel
radgridview
onedrive-api
dynatrace
zerobrane
heat
modbus-tcp
xmonad
ag
undertow
blade
jquery-ias
question2answer
draft-js-plugins
jquery-multiselect
angular-translate
winexe
datastax-enterprise-graph
gp
cart
deltaspike
dumpbin
fstream
code-snippets
reactjs.net
installscript
python-import
imx6
timing
protein-database
chef-solo
c9.io
visa
microsoft-metro
oracle-service-bus
knime
apache-spark-dataset
uiimage
gitlist
yii2-api
tinymce-3
tinkerpop
modelsim
css-transforms
universal-analytics
rxtx
pocketsphinx-android
choice
slackware
qtplugin
dup
clipboard.js
deep
cortex-m
fuzzywuzzy
beanstalk
jparsec
custom-errors
tfs-workitem
google-books
opserver
batik
liquid-layout
avahi
canvg
jquery-forms-plugin
delayed-execution
pseudo-class
raygun
build-script
amslidemenu
mysql-error-1044
away3d
isqlquery
ebay-lms
gpars
time.h
video-codecs
correlated-subquery
ilasm
ikimagebrowserview
saxparseexception
tournament
massive
vs-android
sifr
filesystemobject
silverlight-oob
xslcompiledtransform
blind

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