{"id":20309,"date":"2019-06-18T08:14:08","date_gmt":"2019-06-17T23:14:08","guid":{"rendered":"https:\/\/agrimo.jp\/wp\/?page_id=20309"},"modified":"2019-06-21T12:31:09","modified_gmt":"2019-06-21T03:31:09","slug":"10-newtonsoft-json-net-%e3%80%80%ef%bc%88json%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%ef%bc%89","status":"publish","type":"page","link":"https:\/\/agrimo.jp\/wp\/?page_id=20309","title":{"rendered":"10.Newtonsoft Json.NET \u3000\uff08JSON\u30e9\u30a4\u30d6\u30e9\u30ea\uff09"},"content":{"rendered":"<p>JSON\u30e9\u30a4\u30d6\u30e9\u30ea\uff08Newtonsoft Json.NET\uff09\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>Newtonsoft Json.NET \u306f\u3001\u30a2\u30b0\u30ea\u30e2\u306e\u88fd\u54c1\u3067\u306f\u6bd4\u8f03\u7684\u3088\u304f\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u7528\u9014\u3068\u3057\u3066\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067 DB\u306eDataTable\u3092JSON\u306b\u5909\u63db\u3057\u3066Socket\u901a\u4fe1\u3067\u9001\u308a\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3067\u53d7\u4fe1\u3057\u305fJSON\u304b\u3089DataTable\u306b\u623b\u3059\u3068\u3044\u3063\u305f\u3053\u3068\u306b\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Socket\u901a\u4fe1\u306f\u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u6587\u5b57\uff08\u7279\u306b\u65e5\u672c\u8a9e\u306e2\u30d0\u30a4\u30c8\u6587\u5b57\uff09\u306e\u8003\u616e\u304c\u91cd\u8981\u3067\u3001\u9001\u4fe1\u6642\u306b\u4e0d\u5177\u5408\u304c\u3042\u308b\u3068\u6587\u5b57\u5316\u3051\u3092\u8d77\u3053\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u6700\u8fd1\u306f\u3001\u6587\u5b57\u5316\u3051\u304c\u8d77\u304d\u308b\u5834\u6240\u3067\u306fWCF\u3078\u306e\u7f6e\u304d\u63db\u3048\u3092\u56f3\u3063\u3066\u3044\u307e\u3059\u3002WCF\u3067\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u304b\u3089\u30b5\u30fc\u30d0\u30fc\u5074\u306eDB\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u304c\u53ef\u80fd\u306b\u3067\u304d\u308b\u306e\u3067\u3001JSON\u3067\u9001\u53d7\u4fe1\u3059\u308b\u5fc5\u8981\u306f\u306a\u304f\u306a\u308a\u3001 Android\u3084Web\u3068\u306e\u901a\u4fe1\u7528\u306b\u9650\u3089\u308c\u3064\u3064\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\uff11\uff0e\u65b0\u898f\u306b\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 40px;\"><a href=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-20582\" src=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33-300x160.png 300w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33-1024x546.png 1024w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33-50x27.png 50w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33-820x437.png 820w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h21_33.png 1363w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\uff12\uff0e\u30d1\u30c3\u30b1\u30fc\u30b8\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u3001\u300cInstall-Package Newtonsoft.Json\u300d\u3068\u5165\u529b\u3057\u3066Enter\u30ad\u30fc\u3092\u62bc\u4e0b\u3057\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 40px;\"><a href=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-20584\" src=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02-300x160.png 300w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02-1024x545.png 1024w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02-50x27.png 50w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02-820x437.png 820w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_02.png 1363w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\uff13\uff0e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u53c2\u7167\u306bDLL\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p style=\"padding-left: 40px;\"><a href=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-20585\" src=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45-300x160.png 300w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45-1024x545.png 1024w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45-50x27.png 50w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45-820x436.png 820w, https:\/\/agrimo.jp\/wp\/wp-content\/uploads\/2019\/06\/2019-06-21_11h23_45.png 1362w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9<\/p>\n<pre class=\"lang:default decode:true \" title=\"\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\">\/\/\u7269\u4ef6\u60c5\u5831\u306e\u8aad\u307f\u8fbc\u307f\r\nDataSet wDs = new DataSet();\r\nReinsRenkeiSql wSql = new ReinsRenkeiSql();\r\nstring sqlStr = wSql.get_Bukken_Sql(pShiborikomiWhere, \"\");\r\nusing (SqlCeDataAdapter da = new SqlCeDataAdapter(sqlStr, conn))\r\n{\r\n    da.Fill(wDs);\r\n    da.Dispose();\r\n}\r\n\r\nwDs.DataSetName = \"\u7269\u4ef6\";\r\nwDs.Tables[0].TableName = \"\u30c7\u30fc\u30bf\";\r\n\r\nif (wDs.Tables[0].Rows.Count &gt; 0)\r\n{\r\n    \/\/\u30d5\u30a1\u30a4\u30eb\u9078\u629e\u30c0\u30a4\u30a2\u30ed\u30b0\u8868\u793a\r\n    SaveFileDialog f = new SaveFileDialog();\r\n    f.FileName = \"\u7d5e\u308a\u8fbc\u307f\u7269\u4ef6\u30c7\u30fc\u30bf.json\";\r\n    f.Filter = \"JSON\u30d5\u30a1\u30a4\u30eb(*.json)|*.json|\u3059\u3079\u3066\u306e\u30d5\u30a1\u30a4\u30eb(*.*)|*.*\";\r\n    f.Title = \"\uff2a\uff33\uff2f\uff2e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\";\r\n    f.CheckPathExists = true;\r\n    f.RestoreDirectory = true;\r\n\r\n    string save_fname = \"\";\r\n    if (f.ShowDialog() == DialogResult.OK)\r\n    {\r\n        save_fname = f.FileName;\r\n        f.Dispose();\r\n    }\r\n    else\r\n    {\r\n        f.Dispose();\r\n        \/\/\u5143\u306b\u623b\u3059\r\n        Cursor.Current = Cursors.Default;\r\n        return;\r\n    }\r\n\r\n    \/\/\u5f85\u6a5f\u72b6\u614b\r\n    Cursor.Current = Cursors.WaitCursor;\r\n\r\n    string json = JsonConvert.SerializeObject(wDs, Newtonsoft.Json.Formatting.Indented);\r\n\r\n    \/\/JSON\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\r\n    StreamWriter SW = null;\r\n    \/\/\u30b9\u30c8\u30ea\u30fc\u30e0\u3092UTF-8\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3067\u4f5c\u6210\r\n    SW = new StreamWriter(save_fname, false, System.Text.Encoding.GetEncoding(\"utf-8\"));\r\n    \/\/DataSet\u306e\u30c7\u30fc\u30bf\u3092JSON\u306b\u66f8\u304d\u8fbc\u3080\r\n    SW.Write(json);\r\n    SW.Close();\r\n\r\n    \/\/\u5143\u306b\u623b\u3059\r\n    Cursor.Current = Cursors.Default;\r\n\r\n    MessageBox.Show(this, \"\u7d5e\u308a\u8fbc\u307f\u7269\u4ef6\u30c7\u30fc\u30bf\u306e\uff2a\uff33\uff2f\uff2e\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\", \"\u78ba\u8a8d\", MessageBoxButtons.OK, MessageBoxIcon.Information);\r\n}\r\nelse\r\n{\r\n    MessageBox.Show(this, \"\u7d5e\u308a\u8fbc\u307f\u7269\u4ef6\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u305b\u3093\u3002\", \"\u78ba\u8a8d\", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JSON\u30e9\u30a4\u30d6\u30e9\u30ea\uff08Newtonsoft Json.NET\uff09\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002 Newtonsoft  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-20309","page","type-page","status-publish","hentry"],"wppr_data":{"cwp_meta_box_check":"No"},"_links":{"self":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/20309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20309"}],"version-history":[{"count":11,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/20309\/revisions"}],"predecessor-version":[{"id":20590,"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=\/wp\/v2\/pages\/20309\/revisions\/20590"}],"wp:attachment":[{"href":"https:\/\/agrimo.jp\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}