views:

68

answers:

2

I have a simple call

JSON.parse(Panda.get("/videos/#{self.panda_video_id}/encodings.json"))

Which returns :

can't convert Array into String

This is because the Panda.get("/videos/#(self.panda_video_id}/encodings.json") call returns an array in the new Panda 1.0.0 gem.

I also tried :

JSON.parse(Panda.get("/videos/#{self.panda_video_id}/encodings.json").to_s)

This returns:

705: unexpected token at 'created_at2010/07/19 20:28:13 +0000video_id4df3be7b6c6888ae86f7756c77c92d8bupdated_at2010/07/19 20:28:30 +0000started_encoding_at2010/07/19 20:28:21 +0000id6e2b35ad7d1ad9c9368b473b8acd0abcextname.mp4encoding_time0encoding_progress100file_size513300height110statussuccesswidth200profile_idf1eb0fe2406d3fa3530eb7324f410789'

Question

How would you turn the call at the top so that it returns a string?

+1  A: 

does the following work:

panda_data = Panda.get("/videos/#{self.panda_video_id}/encodings.json")
JSON.parse(panda_data.to_s)

if it doesn't what is the error output?

If panda_data is an array, panda_data.to_s is guaranteed to return a string

ennuikiller
You obviously didn't read my post :D
Trip
I updated my post with the error.
Trip
you know I just copied the wrong line from your question....but I understand you thinking I didn't read the whole thing :)
ennuikiller
Clever gravatar btw. Offtopic : Huge Kubrick fan <--
Trip
thx! maybe you'll reconsider and upvote to 0?
ennuikiller
It does do a string, but then it ( i believe ) it turns its object into a string as well. i need it to stay an object. just an object without an array.
Trip
For some awful reason, you can't neutralize a 0. So I commend your effort instead ;)
Trip
+1  A: 

Not that anyone had a chance at this, but

Panda_Gem since -v=0.6 has made all Panda.[get, post, etc.] requests return a hash. So you don't need the JSON.parse anymore. Removing the JSON.parse allows it to work.

Trip
In fact even that interface is deprecated in favor of `Panda::Video.find` described here: http://github.com/newbamboo/panda_gem.
bjg