JSON.NETを使用して(JSONで返された)いくつかのredditコメントを逆シリアル化しようとしています。コメントに「返信」フィールドがあり、これは別のコメントオブジェクトか空の引用符( "")です。問題は、JSON.NETデシリアライザが、オブジェクトを期待しているフィールドをデシリアライズするときに例外をスローしますが、 ""(これは ""ではなくヌルを探していると思います)です。フィールドのnullではなく空の引用符を使用するJSON.NETを使用してJSON文字列を逆シリアル化できますか?
例:
"data":{
"body":"We were being trolled. ",
"subreddit_id":"t5_2qh1i",
"author_flair_css_class":null,
"created":1318984933.0,
"author_flair_text":null,
"downs":1,
"author":"evange",
"created_utc":1318959733.0,
"body_html":"<div class=\"md\"><p>We were being trolled.</p></div>",
"levenshtein":null,
"link_id":"t3_lghhj",
"parent_id":"t3_lghhj",
"likes":null,
"replies":"",
"id":"c2shf1a",
"subreddit":"AskReddit",
"ups":6,
"name":"t1_c2shf1a"
}
そして、これは次のとおりです。
"data":{
"body":"Dude, it was a Roll Troll. Forget it.",
"subreddit_id":"t5_2qh1i",
"author_flair_css_class":null,
"created":1318985233.0,
"author_flair_text":null,
"downs":1,
"author":"youngmonk",
"created_utc":1318960033.0,
"body_html":"<div class=\"md\"><p>Dude, it was a Roll Troll. Forget it.</p></div>",
"levenshtein":null,
"link_id":"t3_lghhj",
"parent_id":"t3_lghhj",
"likes":null,
"replies":{
"kind":"Listing",
"data":{
"modhash":"",
"children":[....etc
JSON.NETでこれをデシリアライズする方法はありますか、私は、「検索する正規表現を行う必要があります返信 ":" "空の引用符をすべてnullに変更しますか?
ありがとうございます!
[JSON.netの 'NullValueHandling'設定](http://james.newtonking.com/projects/json/help/SerializationSettings.html)を調べましたか? – NT3RP
私はそれを見ていなければなりません - 値がnullならOKですが、 "" sが問題を引き起こしていると思います。デシリアライザでnullを扱うことができます先端! – codechinchilla