2016-03-29 21 views
0

私のCMSには、私が挿入するさまざまなデータに対してjsonレスポンスがあり、JSON形式で取得します。JSONから特殊文字をデコードする方法。 (例: "'"から "'")

ie。

[{"id":"7","image":"vangal.jpe","name":"Louis Van Gaal","nationality":"Dutch","managed_from":"14 July 2014", 
"article":"Louis van Gaal arrived at Manchester United with an outstanding record of success first in his native Netherlands and subsequently at some of the biggest clubs in the world.\r\n\r\nAs a manager he has won league titles in three different countries, guided a youthful Ajax side to UEFA Champions League glory, as well as lifting the UEFA Cup. His second stint in charge of the Dutch national team ended with the Netherlands making the semi-finals of the 2014 World Cup, a run which included a magnificent 5-1 win over holders Spain.\r\n\r\nBorn Aloysius Paulus Maria van Gaal in Amsterdam on 8 August 1951, he joined Ajax aged 20 and while he never played for the great Dutch club's first team, the influence of the time he spent immersed in its culture of Total Football has never left him.\r\n\r\nHe cut his teeth at professional level after moving over the border to Royal Antwerp in Belgium, but following four years there he returned to Holland to complete his playing career, briefly at Telstar, then for eight years at Sparta Rotterdam before retiring after a short stint at AZ.\r\n\r\nVan Gaal remained at AZ to begin a coaching and management career where the characteristics of fluent passing, talented youngsters being given a chance and canny tactics through a high attention to detail have remained to great effect at the highest level of the global game.\r\n\r\nAfter leaving AZ, van Gaal's coaching education continued under the legendary Leo Beenhakker at Ajax, who he succeeded as first team boss in 1991. The club's fortunes had dipped since the golden era of the 1970s, but under van Gaal Ajax secured three consecutive Eredivisie titles and the UEFA Cup. But more importantly they delivered European Cup success, in its new guise as the Champions League, returning the trophy to the club for the first time in over 20 years.\r\n\r\nA side containing future United star Edwin van der Sar, the De Boer brothers, Frank Rijkaard, Edgar Davids, Clarence Seedorf, Marc Overmars and Patrick Kluivert overcame AC Milan in Vienna, and after this success it was inevitable that van Gaal would be linked with some of the biggest clubs in Europe. He eventually succeeded Bobby Robson at Barcelona in 1997, and after inheriting a set-up that included Jose Mourinho on the coaching staff, his new side won La Liga in his first season in charge, retaining the title the following year.\r\n\r\nWhile at Barca, van Gaal had the first of four meetings with United in the Champions League, handing an 18-year-old Xavi his European debut during the 3-3 draw at Old Trafford. The first goalscorer that night? Ryan Giggs.\r\n\r\nVan Gaal then had spells in charge of the Dutch national side and the Catalan giants again, and following a brief time at Ajax as technical director he returned to AZ and guided them to the Dutch title in 2009.\r\n\r\nThis dramatic success led to Bayern Munich recruiting him, and van Gaal became the first Dutch manager to win the Bundesliga, claiming a league title in his debut season in charge at a club for the second time β something Reds fans would love to see him do again at United.\r\n\r\nA second Champions League final for van Gaal, in 2010, ended in defeat to an Inter Milan side managed by former assistant Mourinho, and after leaving Bayern he took up the reins of the Dutch national side once again and successfully steered them through to the 2014 World Cup finals. The Netherlands won the third place play-off with a 3-0 win over hosts Brazil, but just a few days later van Gaal was officially unveiled in Manchester to begin the next chapter of an already stellar career.\r\n\r\nHis announcement as the next United manager, the club's first continental coach to take charge of the first team, arrived on 19 May 2014. Ryan Giggs was announced as his assistant manager, while assistant coaches Albert Stuivenberg, Frans Hoek (specialising with goalkeepers) and Marcel Bout (focusing on opposition scouting), training physiologist Jos van Dijk and performance analyst Max Reckers also joined a new-look backroom team at Old Trafford.\r\n\r\nVan Gaal, who eventually started work at United on 14 July 2014, said: "It was always a wish for me to work in the Premier League. To work as a manager for Manchester United, the biggest club in the world, makes me very proud. I have managed in games at Old Trafford before and know what an incredible arena it is and how passionate and knowledgeable the fans are. This club has big ambitions; I too have big ambitions. Together I'm sure we will make history.""}] 

この場合、テキストが入った単純なJSON配列があります。しかし、私は'""のようなテキストからいくつかの文字を読むことができません。私はあなたが次のスクリーンショットからそれを見ることができることを願っています。私は文字'のを取り出すことができるどのよう

my screenshot

?それは本当に醜いと読みにくいようです。

Τお幸きです。

+0

これはhtml文字列のようです。テキストをHTMLテキストとして設定する、 'tv.setText(Html.fromHtml(" text "))'、replace()メソッドを使う必要はありません。 –

+0

JSONで '' 'の文字列の中に' \ "を使ってエスケープするか、Unicodeリテラルを使用する必要があります。さらに、ビューコンポーネントへのパスのどこかにHTML文字の引用が行われ、HTML文字エンティティが文字列に導入されているようです。 [Html.fromHtml()](http://developer.android.com/reference/android/text/Html.html#fromHtml%28java.lang.String%29)は、それらを処理できます。しかし、おそらく彼らがそこにいかに到着しているかを知ることは、おそらく役に立つでしょう。 – dhke

答えて

1

使用。

+0

ありがとうございます。それは簡単でした! – Theo

+0

@Theoもしそれがあなたを助けたら、これを正しい答えとして受け入れてください。他人にも役立つかもしれません。 :) – lal

+0

Ooops。ごめんなさい!忘れてた! – Theo

0

JSONが正しくありません。最初にhttp://jsonlint.com/を使用して解析してください。

正しくご理解いただける場合は、'"の問題があります。代わりに\'\"を使用してください。次

myTextView.setText(Html.fromHtml( "ここではURテキスト"))のような

0

返信いただきありがとうございます! というユーザーのおかげで問題は解決しました。

myTextView.setText(Html.fromHtml("ur text here")); 
関連する問題