将Json文件数据加载到表中 [英] Loading Json file data into table

查看:71
本文介绍了将Json文件数据加载到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要使用C#语言将Json文件数据加载到其中一个表中。我怎样才能实现它?

I need to load Json file data into one of the table using C# language. How can i achieve it?

CREATE TABLE [dbo].[Test](
	[Series_ID] [nvarchar](50) NOT NULL,
	[Name] [nvarchar](600) NULL,
	[Units] [nvarchar](50) NULL,
	[Frequency] [nvarchar](50) NULL,
	[UnitsShort] [nvarchar](50) NULL,
	[Description] [nvarchar](2000) NULL,
	[Source] [nvarchar](100) NULL,
	[Geography] [nvarchar](50) NULL,
	[Date] [nvarchar](50) NULL,
	[PriceValues] [decimal](18, 5) NULL
) 

JSON文件数据。 JSON数据下方有2015,2016和2017年数据。我只应加载2016年和当前年度,即2017年数据。

JSON File Data. Below JSON data has 2015,2016 and 2017 data. I am only supposed to load 2016 and current year i.e. 2017 data.

{" request":{" command":"系列"," series_id":" PET.WCRRIUS2.W"},"系列":[{" series_id":" PET.WCRRIUS2.W","名称":" US原油的精炼机净输入,每周","单位":"每天桶数千美元","f":"W","单位短程":"Mbbl \ / d"。 ,"描述":" US原油的精炼机净输入,"版权":"无","来源":"EIA,US Energy Information
Administration","iso3166":"USA","geography" ;:"美国","开始":" 19820820","末端":" 20170609","更新":" 2017-06-14T13:17:45-0400","数据" ;:[[" 20170609",17256],[" 20170602",17227],[" 20170526",17510],[" 20170519",17281],[" 20170512",17122],[" ; 20170505",16759],[" 20170428",17177],[" 20170421",17285],[" 20170414",16938],[" 20170407",16697],[" 20170331",16429 ],[" 20170324",16226],[" 20170317",15801],[" 20170310",15472],[" 20170303",15492],[" 20170224",15664],[" 20170217",15271],[" 20170210",15458],[" 20170203",15893],[" 20170127",15947],[" 20170120",16047],[" 20 170113",16468],[" 20170106",17107],[" 20161230",16689],[" 20161223",16557],[" 20161216",16658],[" 20161209",16474] [" 20161202",16417],[" 20161125",16283],[" 20161118",16397],[" 20161111",16126],[" 20161104",15817],[" 20161028" ;,15448],[" 20161021",15552],[" 20161014",15370],[" 20161007",15552],[" 20160930",16032],[" 20160923",16334], [" 20160916",16587],[" 20160909",16730],[" 20160902",16930],[" 20160826",16615],[" 20160819",16679],[" 20160812" ,16865],[" 20160805",16597],[" 20160729",16852],[" 20160722",16586],[" 20160715",16863],[" 20160708",16544],[ " 20160701",16687],[" 20160624",16695],[" 20160617",16505],[" 20160610",16317],[" 20160603",16417],[" 20160527" ;, 16206],[" 20160520",1 6279],[" 20160513",16371],[" 20160506",16179],[" 20160429",15986],[" 20160422",15847],[" 20160415",16104],[" ; 20160408",15941],[" 20160401",16433],[" 20160325",16234],[" 20160318",15820],[" 20160311",15996],[" 20160304",15911 ],[" 20160226",15852],[" 20160219",15685],[" 20160212",15848],[" 20160205",15510],[" 20160129",15615],[" 20160122",15639],[" 20160115",16190],[" 20160108",16423],[" 20160101",16617],[" 20151225",16682],[" 20151218",16468] ]}]}

{"request":{"command":"series","series_id":"PET.WCRRIUS2.W"},"series":[{"series_id":"PET.WCRRIUS2.W","name":"U.S. Refiner Net Input of Crude Oil, Weekly","units":"Thousand Barrels per Day","f":"W","unitsshort":"Mbbl\/d","description":"U.S. Refiner Net Input of Crude Oil","copyright":"None","source":"EIA, U.S. Energy Information Administration","iso3166":"USA","geography":"USA","start":"19820820","end":"20170609","updated":"2017-06-14T13:17:45-0400","data":[["20170609",17256],["20170602",17227],["20170526",17510],["20170519",17281],["20170512",17122],["20170505",16759],["20170428",17177],["20170421",17285],["20170414",16938],["20170407",16697],["20170331",16429],["20170324",16226],["20170317",15801],["20170310",15472],["20170303",15492],["20170224",15664],["20170217",15271],["20170210",15458],["20170203",15893],["20170127",15947],["20170120",16047],["20170113",16468],["20170106",17107],["20161230",16689],["20161223",16557],["20161216",16658],["20161209",16474],["20161202",16417],["20161125",16283],["20161118",16397],["20161111",16126],["20161104",15817],["20161028",15448],["20161021",15552],["20161014",15370],["20161007",15552],["20160930",16032],["20160923",16334],["20160916",16587],["20160909",16730],["20160902",16930],["20160826",16615],["20160819",16679],["20160812",16865],["20160805",16597],["20160729",16852],["20160722",16586],["20160715",16863],["20160708",16544],["20160701",16687],["20160624",16695],["20160617",16505],["20160610",16317],["20160603",16417],["20160527",16206],["20160520",16279],["20160513",16371],["20160506",16179],["20160429",15986],["20160422",15847],["20160415",16104],["20160408",15941],["20160401",16433],["20160325",16234],["20160318",15820],["20160311",15996],["20160304",15911],["20160226",15852],["20160219",15685],["20160212",15848],["20160205",15510],["20160129",15615],["20160122",15639],["20160115",16190],["20160108",16423],["20160101",16617],["20151225",16682],["20151218",16468]]}]}

谢谢

赛义德

推荐答案

https ://www.codeproject.com/Tips/79435/Deserialize-JSON-with-C

然后你可以使用C#对象并使用参数化的T-SQL来读取的性质对象一个参数。

Then you can take the C# object and use parameterized T-SQL to read properties of the object a parameters.


这篇关于将Json文件数据加载到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆