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
url-redirection
beautifulsoup
adal
codenvy
pyqt
numbers
shiro
rendering
nsbundle
google-apps
vsm
tvos
nstableheaderview
barcode
joomla3.0
teechart
jquery-ui-sortable
vimdiff
fhir
startup
gource
powershell-v5.0
google-data-studio
guzzle
dpdk
r-mice
epsilon
interpreter
dynamically-generated
perlbrew
draft-js-plugins
froala
dapper-extensions
motion-detection
corpus
outliers
inversion-of-control
sqsh
nsurl
postback
paragraph
cart
android-maps-extensions
activexobject
jwplayer6
xcode7.3
ideascript
mcustomscrollbar
vmware-fusion
skylink
tcc
berkeley-db-je
oim
opencmis
clarifai
reindex
edit
oozie-coordinator
slackware
file-uri
cifilter
lua-telegram-bot
gcloud-ruby
nio2
kendo-upload
relativelayout
opl
avisynth
computer-architecture
opserver
extjs-grid
canalyzer
keyup
aspectj-maven-plugin
matlab-deployment
fail2ban
diff3
openbabel
grouping-sets
sonarqube-5.0
trdion2011
unix-socket
angular-carousel
dct
draw2d-js
hibernate-entitymanager
dtmf
abstract-data-type
virtual-pc
argouml
jdb
cgimage
android-holo-everywhere
codebase
cac
luajava
timertask
globals
qtabbar
burndowncharts
strtod
flvplayback
unmanagedresources

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