Thursday, 15 March 2012

ruby - rails decode json cyrrilic string -


itemprop = "text">

I have a string example that I get from json (CP1251):

  Ôèëüòð Ìàñëííûé OPEL / GM / DAUOO  

means:

  Filter M / s Opel / GM / Demo  

This tool says that I have to use CP1252 → CP1251 decoder. I try this much:

  my_string.force_encoding ('cp1252') force_encoding ('1251')  

but it did not resolve my problem. . How can i do wrong

How can I change my Jason Cyrillic string in ROR normally?

I get Jasonson from the URL:

  jsonAE = JSON.load (open ('http: //*****/portal.apil = * **** & P = Sih2 ***** & amp; function = price_by_nr_firm & NR = 'From Json I:  
  {"Result": [ "" "": "" "" "" "" "" ":" "" "" "" "" "" ":" "" "": "" "" "" "" "" "" "" "": "" "" " Knecht "," name ":" Фильтр opal / GM / Daewoo масляный "," share ":" - "," distribution ":" не известно "," minq ":" 1 "," upd ":" 17.03.15 00:05 "," value ":" 130.34 "," currency ":" руб. "}]}  

After that, text "itemprop =" text ">

  .encode ▶ put 'opal after  JSON.load  

Hope it helps.


No comments:

Post a Comment