-1

次の文字列を返す関数の 1 つ:

{
   "data": [{
      "type": "facebook",
      "id": "639422616",
      "name": "Neal Cabage",
      "message": "Ruby on rails or Sinatra better for a restful app that speaks json, not html?"
   }, {
      "type": "facebook",
      "id": "100001604824773",
      "name": "Christolle Soragee",
      "message": "When you lose: "
      Who cares ? !It 's just a game!" When you win: "HAHAHA IN YOUR FACE LOSER!""},{"type":"facebook","id":"100000049925091","name":"Chris Cassanova Dunphy","message":"It'
      s sad when you already know you 're gonna get ripped off and you have to junkie proof your stash... Hahaha good thing I was on point! It'
      s funny how people with a problem will ruin a good thing just "}]}

を使用するjQuery.parseJSON(response)と、メッセージ内に二重引用符が含まれている場合に例外がスローされます。

どんな助けや提案も大歓迎です。

ありがとう

4

1 に答える 1

1

json.orgによると:

文字列は、バックスラッシュ エスケープを使用して二重引用符で囲まれた 0 個以上の Unicode 文字のシーケンスです。文字は、1 つの文字列として表されます。文字列は、C または Java の文字列に非常によく似ています。

弦

そのため、文字列内の など"の文字は でエスケープする必要があり\、結果は のようになり"This is my string with a quote \" inside it"ます。

于 2012-05-04T12:02:59.380 に答える