Given a string in the following format (Posterous API returns messages in this format):
s="\\u003Cp\\u003E"
How can I convert it to actual ascii characters so that s="<p>"?
I successfully used it on OSX Iconv.iconv('ascii', 'java', s), but after deploying it to Heroku, I got an exception Iconv::IllegalSequence. I assume that the Heroku system deployed does not support the encoder java.
I use HTTParty to make a request to the Posterous API. If I use curl to make the same request, I do not get double slashes.
On the httparty github page:
Automatically parse JSON and XML into ruby hashes based on Content-Type response
The Posterous API returns JSON (without double slashes), and the HTTParty JSON partition inserts a double slash.
, HTTParty .
class Posterous
include HTTParty
base_uri "http://www.posterous.com/api/2"
basic_auth "username", "password"
format :json
def get_posts
response = Posterous.get("/users/me/sites/9876/posts&api_token=1234")
end
end
( , , site_id, api_token) .
snip response.body Ruby, JSON, response.parsed_response Ruby, HTTParty JSON Posterous API.
Unicode, \u003C, \\u003C.