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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

you know I just copied the wrong line from your question....but I understand you thinking I didn't read the whole thing :)
Clever gravatar btw. Offtopic : Huge Kubrick fan <--
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.
For some awful reason, you can't neutralize a 0. So I commend your effort instead ;)
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.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.