2017-03-28 15 views
0

正常に動作している通常のコンテンツで私のjsonデータをテストしました。以下のようにJsonはファイルの内容で検証していませんか?

S 十分なデータ:

ワーキングJSON

{ 
    "language": "XYZ", 
    "content": { 
    "GEN": "this is test", 
    "EXO": "this is test" 
    } 
} 

に動作していないJSON

{ 
    "language": "XYZ", 
    "content": { 
    "GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.", 
    "EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah" 
    } 
} 

Check screenshot for working and not working json

+0

あなたのスクリーンショットでは、2つのJSONオブジェクトを連続してペーストしているように見えます。 – deceze

+0

しかし、私はちょうど働いている情報と別のものが動作していないために添付されています。 –

答えて

0

、あなたはJSON文字列にあなたのオブジェクトを変換して、これはあなたに、よりシンプルになります

この下の
var obj= { 
      "language": "XYZ", 
      "content": { 
       "GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.", 
       "EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah" 
      } 
     }; 
     var json= JSON.stringify(obj); 

のように解析することができます。

+0

これも役に立ちます。 –

1

だけバックスラッシュエスケープシーケンスJSON許可はです、\f\n\r\tおよび\"である。その他のバックスラッシュの使用は、すべて\\としてエスケープする必要があります。問題は、\i(およびその他のエスケープシーケンスのいくつか)がJSONに何も意味を持たず、したがって構文エラーであるということです。代わりに\\iとしてください。エスケープシーケンスについては

+0

うん、今うまく動作します。ありがとうございました。 –

関連する問題