Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top