问题描述
任何人如何使用C#.Net编码创建一个JSon文件以下
{gstin:37AAKCA3416B1Z3,
fp:012019,
gt:0.00,
cur_gt:0.00,
b2b:
[{ctin:27AALCS1893B1Z8,
inv:[{inum:AAA1819KRI0482,
idt :03-01-2019,
val:13310.00,
pos:27,
rchrg :N,
itms:[{num:1,
itm_det:{txval:11280.00,
rt:18,
iamt:2030.40,
csamt:0.00}}],
inv_typ :R}]},
{ctin:33AAJCS4246C1ZM,
inv:[{inum :AAA1819KRI0483,
idt:04-01-2019,
val:13794.00,
pos :33,
rchrg:N,
itms:[{num:1,
itm_det:{txval:11690.00,
rt:18,
iamt:2104.20,
csamt :0.00}}},
inv_typ:R},
{inum:AAA1819KRI0484,
idt : 0 5-01-2019,
val:360.00,
pos:33,
rchrg: N,
itms:[{num:1,
itm_det:{txval:305.00,
rt:18,
iamt:54.90,
csamt:0.00}}],
inv_typ: R}]}
,{ctin:33AAECM0106G1Z6,inv:[{inum: AAA1819KRI0485\" , IDT: 2019年5月1日, VAL:531.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det :{ txval :450.00, RT :18,iAMT的 :81.00, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0494\" , IDT : 2019\" 年10月1日, VAL:46173.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:39129.00, RT:18 iAMT的:7043.22, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0495, IDT: 2019\" 年11月1日, VAL:99027.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval: 83921.00, RT:18 iAMT的:15105.78, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0501, IDT:18-01- 2019\" , VAL:20010.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:16958.00,RT :18, iAMT的 :3052.44, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0515, IDT: 28-01-2019, VAL:46658.00,POS : 33\" , rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:39540.00, RT:18 iAMT的:7117.20, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0517\" , IDT: 31-01-2019, VAL:13626.00, POS:33 , rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:11548.00, RT:18 iAMT的:2078.64, CSAMT:0.00 }}], inv_typ: R},{ INUM: AAA1819KRI0518, IDT: 31-01-2019, VAL:6818.00, POS: 33,rchrg : N, ITMS:[{ NUM:1, itm_det:{ txval:5778.00, RT:18 iAMT的:1040.04, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0519, IDT: 31-01-2019, VAL:6830.00, POS: 33, rchrg:N , ITMS:[{ NUM:1, itm_det:{ txval:5788.00, RT:18 iAMT的:1041.84, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0527, IDT: 31-01-2019, VAL:13300.00, POS: 33, rchrg: N,ITMS :[{ NUM :1, itm_det :{ txval :11271.00, RT :18,iAMT的 :2028.78, CSAMT :0.00}}], inv_typ : R} ]},{ 一个已将: 33AAECP8284A1ZK, INV:[{ INUM: AAA1819KRI0486 , IDT: 2019年5月1日, VAL:531.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det :{ txval:450.00, RT:18 iAMT的:81.00, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 33AADCT4957H2Z6, INV :[{ INUM : AAA1819KRI0487\" , IDT: 2019年5月1日, VAL:1782.00, POS: 33, rchrg: N, ITMS :[{ NUM:1, itm_det:{ txval:1510.00, RT:18 iAMT的:271.80, CSAMT:0.00}}], inv_typ: R}, { INUM: AAA1819KRI0493, IDT: 2019年9月1日, VAL:1607.00, POS: 33, rchrg: N, ITMS:[{ NUM :1, itm_det :{ txval :1360.00, RT :18,iAMT的 :244.80, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0523, IDT: 31-01-2019, VAL:1719.00, POS: 33, rchrg: N, ITMS:[{ NUM:1 itm_det:{ txval:1455.00, RT:18 iAMT的:261.90, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 33AAICM4989M1ZQ, INV:[{ INUM: AAA1819KRI0488, IDT: 2019年5月1日, VAL:254.00, POS: 33, rchrg: N ITMS:[{ NUM:1, itm_det:{ txval:215.00, RT:18 iAMT的:38.70, CSAMT:0.00}}], inv_typ: R }]},{ 一个已将 : 33AAJFJ8903A1ZP INV:[{ INUM: AAA1819KRI0489, IDT: 05- 01-2019\" , VAL:6308.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:5345.00, RT:18 iAMT的:962.10, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0490, IDT: 2019年8月1日 , VAL:14111.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:11958.00, RT: 18, iAMT的:2152.44, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0496, IDT: 18-01-2019, VAL :6835.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:5792.00, RT:18,iAMT的:1042.56, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0502\" , IDT: 18-01-2019, VAL:6906.00, POS : 33\" , rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:5853.00, RT:18 iAMT的:1053.54, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0504, IDT: 22-01-2019, VAL:7329.00, POS: 33,rchrg:N,itms:[{num:1,itm_det:
{txval:6211.00,rt:18,iamt :1117.98, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0505\" , IDT: 22-01-2019, VAL:7329.00, POS : 33\" , rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:6211.00,R吨 :18,iAMT的 :1117.98, CSAMT :0.00}}], inv_typ : R },{ INUM : AAA1819KRI0526\" , IDT: 31-01-2019, VAL:13701.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:11611.00, RT:18 iAMT的:2089.98, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 37AAECV4603R2ZR, INV:[{ INUM: AAA1819KRI0492, IDT: 2019年9月1日, VAL:25983.00, POS: 37, rchrg: N, ITMS:[{ NUM:1, itm_det:
{txval:22019.00,rt:18,camt:1981.71,samt:1981.71,csamt:0.00}}],inv_typ:R} ]},{ 一个已将: 27AAQCS2565P1ZF, INV:[{ INUM: AAA1819KRI0498, IDT: 18-01-2019, VAL:29041.00, POS:27 , rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:24611.00, RT:18 iAMT的:4429.98, CSAMT:0.00 }}], inv_typ: R},{ INUM: AAA1819KRI0500, IDT: 18-01-2019, VAL:14521.00, POS: 27,rchrg : N, ITMS:[{ NUM:1, itm_det:{ txval:12306.00, RT:18 iAMT的:2215.08, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0514, IDT: 28-01-2019, VAL:43533.00, POS: 27, rchrg:N , ITMS:[{ NUM:1, itm_det:{ txval:36892.00, RT:18 iAMT的:6640.56, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0525, IDT: 31-01-2019 , VAL:14480.00, POS: 27, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:12271.00, RT: 18, iAMT的:2208.78, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 27AAHCM3698Q1ZG, INV:[{ INUM: AAA1819KRI0503 , IDT: 18-01-2019, VAL:28106.00, POS: 27, rchrg: N, ITMS:[{ NUM:1, itm_det :{ txval:23819.00, RT:18 iAMT的:4287.42, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 33AAJCA2904R1ZG, INV :[{ INUM : AAA1819KRI0507\" , IDT: 23-01-2019, VAL:12490.00, POS: 33, rchrg: N, ITMS :[{ NUM:1, itm_det:{ txval:10585.00, RT:18 iAMT的:1905.30, CSAMT:0.00}}], inv_typ: R}, { INUM: AAA1819KRI0510, IDT: 25-01-2019, VAL:2360.00, POS: 33, rchrg: N, ITMS:[{ NUM :1, itm_det :{ txval :2000.00, RT :18,iAMT的 :360.00, CSAMT :0.00}}], inv_typ : R }]},{一个已将 : 33AAACD0474C1ZC, INV:[{ INUM: AAA1819KRI0508, IDT: 24-01-2019, VAL:68833.00, POS: 33, rchrg : N, ITMS:[{ NUM:1, itm_det:{ txval:58 333.00, RT:18 iAMT的:10499.94, CSAMT:0.00}}], inv_typ: R},{ INUM: AAA1819KRI0509, IDT:24-01- 2019\" , VAL:40021.00, POS: 33, rchrg: N, ITMS:[{ NUM:1, itm_det:{ txval:33916.00,RT :18,iAMT的 :6104.88, CSAMT :0.00}}], inv_typ : R }]},{ 一个已将 : 27ABACS6699B1Z3\" , INV:[{ INUM: AAA1819KRI0512\" , IDT: 28-01-2019, VAL:10123.00, POS: 27, rchrg: N, ITMS:[{ NUM:1, itm_det :{ txval :8579.00, RT :18,iAMT的 :1544.22, CSAMT :0.00}}], inv_typ : R }]},{ 一个已将 : 33AACCO6063C1ZU INV:[{ INUM: AAA1819KRI0520, IDT: 31-01-2019, VAL:23702.00, POS: 33, rchrg: N, ITMS :[{ NUM :1, itm_det :{ txval :20087.00, RT :18,iAMT的 :3615.66, CSAMT :0.00}}], inv_typ : R },{ INUM: AAA1819KRI0521, IDT: 31-01-2019, VAL:23734.00, POS: 33, rchrg: N, ITMS:[ { NUM:1, itm_det:{ txval:20114.00, RT:18 iAMT的:3620.52, CSAMT:0.00}}], inv_typ: R}]}, { 一个已将: 33CHMPS0520C1ZR, INV:[{ INUM: AAA1819KRI0522, IDT: 31-01-2019, VAL:24426.00, POS: 33, rchrg : N, ITMS:[{ NUM:1, itm_det:{ txval:20700.00, RT:18 iAMT的:3726.00, CSAMT:0.00}}], inv_typ: R}]},{ 一个已将: 33AAJFR7237B1ZE, INV :[{ INUM: AAA1819KRI0528, IDT: 31-01-2019, VAL:43384.00, POS: 33, rchrg: N, ITMS:[ { NUM:1, itm_det:{ txval:36766.00, RT:18 iAMT的:6617.88, CSAMT:0.00}}], inv_typ: R}]}]
,nil:
{inv:[
{sply_ty:INTRB2B ,expt_amt:256570.00,nil_amt:0.00,ngsup_amt:0.00}
,{sply_ty:INTRAB2B,expt_amt:84533.00,nil_amt:0.00, ngsup_amt:0.00}
]}
,hsn:
{
数据:[
{num:1,hsn_sc:996521,desc:海运收入不含税,uqc:OTH ,qty:0,val:140278.00,txval:140278.00,iamt:0.00,camt:0.00,samt:0.00,csamt:0.00}
,{num:2,hsn_sc:996799,desc:CONTAINER SEAL CHGS INCOME,uqc:OTH,qty:0,val:2311.62, txval:1959.00,iamt:157.50,camt:97.56,samt:97.56,csamt:0.00}
,{num:3,hsn_sc: 996711\" , 说明: THC收费收入,uqc:OTH,qty:0,val:504860.64,txval:427848.00,iamt:73772.64,camt:1620.00,samt:1620.00, csamt:0.00},{num:4,hsn_sc:996713,desc:BL CHARGES INCOME,uqc:OTH,qty:0,val:9440.00 txval:8000.00, iAMT的:990.00, CAMT:225.00, SAMT:225.00, CSAMT:0.00},{ NUM:5 hsn_sc: 996711, 降序 :MUC收入,uqc:OTH,数量:0,val:12832.50,txval:10875.00,iamt:1879.20,camt:39.15,samt:39.15, csamt:0.00},{num:6,hsn_sc:996711,desc:IGM CHARGES,uqc:OTH,qty:0,val:1947.00 txval:1650.00, iAMT的:297.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:7, hsn_sc: 996711, 降序 :处理费用收入,uqc:OTH,qty:0,val:57761.00,txval:48950.00,iamt:8811.00,camt:0.00,samt:0.00 ,csamt:0.00},{num:8,hsn_sc:996711,desc:容器存储,uqc:OTH,qty:0,val: 8962.10, txval:7595.00, iAMT的:1367.10, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:9 hsn_sc: 996711,降序:修理清洁费,uqc:OTH,qt Y :0, VAL :2790.70, txval :2365.00, iAMT的 :425.70, CAMT :0.00, SAMT :0.00, CSAMT :0.00},{ NUM :10, hsn_sc:996711,desc:调查费,uqc:OTH,数量:0,val:5315.90,txval:4505.00,iamt:810.90,camt :0.00, SAMT :0.00, CSAMT :0.00},{ NUM :11,hsn_sc : 996711\" , 降序: 洗涤, UQC: OTH,数量:0, VAL :7245.20, txval :6140.00, iAMT的 :1105.20, CAMT :0.00, SAMT :0.00, CSAMT :0.00},{ NUM :12, hsn_sc :996711,desc:LOLO CHARGES,uqc:OTH,qty:0,val:7522.50,txval:6375.00,iamt:1147.50,camt :0.00,samt:0.00,csamt:0.00},{num:13,hsn_sc:996711,desc:IT Bond EGM Filling,uqc:OTH, 数量:0, VAL:708.00, txval:600.00, iAMT的:108.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:14, hsn_sc:996521,desc:海运槽非税,uqc:OTH,数量:0,val:189321.00,txval:189321.00,iamt: 0.00,camt:0.00,samt:0.00,csamt:0.00},{num:15,hsn_sc:996711,desc:额外费用收入,uqc: OTH, 数量:0, VAL:40276.94, txval:34133.00, iAMT的:6143.94, camt:0.00,samt:0.00,csamt:0.00},{num:16,hsn_sc:996711,desc:SSR Charges,uqc:OTH, 数量:0, VAL:1180.00, txval:1000.00, iAMT的:180.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:17, hsn_sc:996711,desc:FEEDER CHARGES,uqc:OTH,qty:0,val:2950.00,txval:2500.00,iamt:450.00, camt:0.00,samt:0.00,csamt:0.00},{num:18,hsn_sc:996719,desc:DO CHARGES,uqc:OTH, 数量:0, VAL:25960.00, txval:22000.00, iAMT的:3960.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:19, hsn_sc:996719,desc:文档费用,uqc:OTH,qty:0,val:9440.00,txval:8000.00,iamt:1440.00, camt:0.00,samt:0.00,csamt:0.00},{num:20,hsn_sc:996711,desc:MR Charges Income,uqc:OTH 数量:0, VAL:13570.00, txval:11500.00, iAMT的:2070.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:21 ,hsn_sc:996711,desc:设备便利费,uqc:OTH,qty:0,val:11210.00,txval:9500.00,iamt:1710.00 CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM:2 2,hsn_sc:996711,desc:HBL Manifest,uqc:OTH,qty:0,val:5900.00,txval:5000.00,iamt:900.00 ,camt:0.00,samt:0.00,csamt:0.00},{num:23,hsn_sc:996711,desc:CIC收入,uqc:OTH , 数量:0, VAL:19035.76, txval:16132.00, iAMT的:2903.76, CAMT:0.00, SAMT:0.00, CSAMT:0.00},{ NUM: 24,hsn_sc:996799,desc:BL SURRENDER CHARGES INCOME,uqc:OTH,qty:0,val:2360.00,txval:2000.00,iamt :360.00,camt:0.00,samt:0.00,csamt:0.00},{num:25,hsn_sc:99,desc:运输费收入,uqc : OTH, 数量:0, VAL:11504.00, txval:11504.00, iAMT的:0.00, CAMT:0.00, SAMT:0.00, CSAMT:0.00}]}}
我尝试过:
这是单独的类别文件
class Voureg
{
public string gstin =;
public string fp =;
public string gt =;
public string cur_gt =;
public List< b2blist> ctin {get;组; }
公共类b2blist
{
public string ctin =;
public invlist inv {get;组; }
}
公共类invlist
{
public string inum =;
public string idt =;
public double val = 0;
public int pos = 0;
public string rchrg =;
public string inv_type =;
}
}
来自Button Click事件
iFACTTouch.FAForms.Voureg strjson = new FAForms.Voureg();
DataSet Dtclientgst = new DataSet();
DataTable dtclienttab = new DataTable();
dtcompgst = bobj.GetCompDetailsfrombranchid(Convert.ToInt32(Session [Loginbranchid]。ToString() ));
Dtclientgst = bobj.GetCustomergstinbranchwiseJson();
if(Dtclientgst.Tables.Count> 0)
{
dtclienttab = Dtclientgst.Tables [0];
}
if(dtcompgst.Rows.Count> 0)
{
strjson.gstin = dtcompgst.Rows [0] [gstin]。ToString ();
strjson.fp =012019;
s trjson.gt =0.00;
strjson.cur_gt =0.00;
//j.b2b =;
if(dtclienttab.Rows.Count> 1)
{
for(int i = 0; i< dtclienttab.Rows.Count -1; i ++)
{
if(clientgstin ==)
{
clientgstin = dtclienttab.Rows [i] [ctin ] .ToString();
}
else
{
clientgstin = clientgstin +/+ dtclienttab.Rows [i] [ctin]。ToString();
}
}
}
string [] gstin = clientgstin.Split('/');
for(int k = 0; k< gstin .Length; k ++)
{
strjson.ctin.Add(gstin [k]);
}
}
string JSONResult = Newtonsoft .json.JsonConvert.SerializeObject(strjson);
string path = @D:\ _json\test.json;
if(File.Exists(path))
{
File.Delete(path);
using(var tw = new StreamWriter(path,true))
{
tw.WriteLine(JSONResult.ToString());
tw .Close();
}
}
else if(!File.Exists(path))
{
使用(var tw = new StreamWriter(path,true))
{
tw.WriteLine(JSONResult.ToString());
tw.Close();
}
}
}
}
Any one how to create a JSon File from C#.Net Coding for the below
{"gstin":"37AAKCA3416B1Z3",
"fp":"012019",
"gt":0.00,
"cur_gt":0.00,
"b2b":
[{"ctin":"27AALCS1893B1Z8",
"inv":[{"inum":"AAA1819KRI0482",
"idt":"03-01-2019",
"val":13310.00,
"pos":"27",
"rchrg":"N",
"itms":[{"num":1,
"itm_det":{"txval":11280.00,
"rt":18,
"iamt":2030.40,
"csamt":0.00}}],
"inv_typ":"R"}]},
{"ctin":"33AAJCS4246C1ZM",
"inv":[{"inum":"AAA1819KRI0483",
"idt":"04-01-2019",
"val":13794.00,
"pos":"33",
"rchrg":"N",
"itms":[{"num":1,
"itm_det":{"txval":11690.00,
"rt":18,
"iamt":2104.20,
"csamt":0.00}}],
"inv_typ":"R"},
{"inum":"AAA1819KRI0484",
"idt":"05-01-2019",
"val":360.00,
"pos":"33",
"rchrg":"N",
"itms":[{"num":1,
"itm_det":{"txval":305.00,
"rt":18,
"iamt":54.90,
"csamt":0.00}}],
"inv_typ":"R"}]}
,{"ctin":"33AAECM0106G1Z6","inv":[{"inum":"AAA1819KRI0485","idt":"05-01-2019","val":531.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":450.00,"rt":18,"iamt":81.00,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0494","idt":"10-01-2019","val":46173.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":39129.00,"rt":18,"iamt":7043.22,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0495","idt":"11-01-2019","val":99027.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":83921.00,"rt":18,"iamt":15105.78,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0501","idt":"18-01-2019","val":20010.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":16958.00,"rt":18,"iamt":3052.44,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0515","idt":"28-01-2019","val":46658.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":39540.00,"rt":18,"iamt":7117.20,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0517","idt":"31-01-2019","val":13626.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":11548.00,"rt":18,"iamt":2078.64,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0518","idt":"31-01-2019","val":6818.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":5778.00,"rt":18,"iamt":1040.04,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0519","idt":"31-01-2019","val":6830.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":5788.00,"rt":18,"iamt":1041.84,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0527","idt":"31-01-2019","val":13300.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":11271.00,"rt":18,"iamt":2028.78,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAECP8284A1ZK","inv":[{"inum":"AAA1819KRI0486","idt":"05-01-2019","val":531.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":450.00,"rt":18,"iamt":81.00,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AADCT4957H2Z6","inv":[{"inum":"AAA1819KRI0487","idt":"05-01-2019","val":1782.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":1510.00,"rt":18,"iamt":271.80,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0493","idt":"09-01-2019","val":1607.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":1360.00,"rt":18,"iamt":244.80,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0523","idt":"31-01-2019","val":1719.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":1455.00,"rt":18,"iamt":261.90,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAICM4989M1ZQ","inv":[{"inum":"AAA1819KRI0488","idt":"05-01-2019","val":254.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":215.00,"rt":18,"iamt":38.70,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAJFJ8903A1ZP","inv":[{"inum":"AAA1819KRI0489","idt":"05-01-2019","val":6308.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":5345.00,"rt":18,"iamt":962.10,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0490","idt":"08-01-2019","val":14111.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":11958.00,"rt":18,"iamt":2152.44,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0496","idt":"18-01-2019","val":6835.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":5792.00,"rt":18,"iamt":1042.56,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0502","idt":"18-01-2019","val":6906.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":5853.00,"rt":18,"iamt":1053.54,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0504","idt":"22-01-2019","val":7329.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":
{"txval":6211.00,"rt":18,"iamt":1117.98,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0505","idt":"22-01-2019","val":7329.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":6211.00,"rt":18,"iamt":1117.98,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0526","idt":"31-01-2019","val":13701.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":11611.00,"rt":18,"iamt":2089.98,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"37AAECV4603R2ZR","inv":[{"inum":"AAA1819KRI0492","idt":"09-01-2019","val":25983.00,"pos":"37","rchrg":"N","itms":[{"num":1,"itm_det":
{"txval":22019.00,"rt":18,"camt":1981.71,"samt":1981.71,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"27AAQCS2565P1ZF","inv":[{"inum":"AAA1819KRI0498","idt":"18-01-2019","val":29041.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":24611.00,"rt":18,"iamt":4429.98,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0500","idt":"18-01-2019","val":14521.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":12306.00,"rt":18,"iamt":2215.08,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0514","idt":"28-01-2019","val":43533.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":36892.00,"rt":18,"iamt":6640.56,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0525","idt":"31-01-2019","val":14480.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":12271.00,"rt":18,"iamt":2208.78,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"27AAHCM3698Q1ZG","inv":[{"inum":"AAA1819KRI0503","idt":"18-01-2019","val":28106.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":23819.00,"rt":18,"iamt":4287.42,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAJCA2904R1ZG","inv":[{"inum":"AAA1819KRI0507","idt":"23-01-2019","val":12490.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":10585.00,"rt":18,"iamt":1905.30,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0510","idt":"25-01-2019","val":2360.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":2000.00,"rt":18,"iamt":360.00,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAACD0474C1ZC","inv":[{"inum":"AAA1819KRI0508","idt":"24-01-2019","val":68833.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":58333.00,"rt":18,"iamt":10499.94,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0509","idt":"24-01-2019","val":40021.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":33916.00,"rt":18,"iamt":6104.88,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"27ABACS6699B1Z3","inv":[{"inum":"AAA1819KRI0512","idt":"28-01-2019","val":10123.00,"pos":"27","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":8579.00,"rt":18,"iamt":1544.22,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AACCO6063C1ZU","inv":[{"inum":"AAA1819KRI0520","idt":"31-01-2019","val":23702.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":20087.00,"rt":18,"iamt":3615.66,"csamt":0.00}}],"inv_typ":"R"},{"inum":"AAA1819KRI0521","idt":"31-01-2019","val":23734.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":20114.00,"rt":18,"iamt":3620.52,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33CHMPS0520C1ZR","inv":[{"inum":"AAA1819KRI0522","idt":"31-01-2019","val":24426.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":20700.00,"rt":18,"iamt":3726.00,"csamt":0.00}}],"inv_typ":"R"}]},{"ctin":"33AAJFR7237B1ZE","inv":[{"inum":"AAA1819KRI0528","idt":"31-01-2019","val":43384.00,"pos":"33","rchrg":"N","itms":[{"num":1,"itm_det":{"txval":36766.00,"rt":18,"iamt":6617.88,"csamt":0.00}}],"inv_typ":"R"}]}]
,"nil":
{"inv":[
{"sply_ty":"INTRB2B","expt_amt":256570.00,"nil_amt":0.00,"ngsup_amt":0.00}
,{"sply_ty":"INTRAB2B","expt_amt":84533.00,"nil_amt":0.00,"ngsup_amt":0.00}
]}
,"hsn":
{
"data":[
{"num":1,"hsn_sc":"996521","desc":"Ocean Freight Income Non Tax","uqc":"OTH","qty":0,"val":140278.00,"txval":140278.00,"iamt":0.00,"camt":0.00,"samt":0.00,"csamt":0.00}
,{"num":2,"hsn_sc":"996799","desc":"CONTAINER SEAL CHGS INCOME","uqc":"OTH","qty":0,"val":2311.62,"txval":1959.00,"iamt":157.50,"camt":97.56,"samt":97.56,"csamt":0.00}
,{"num":3,"hsn_sc":"996711","desc":"THC Charges INCOME","uqc":"OTH","qty":0,"val":504860.64,"txval":427848.00,"iamt":73772.64,"camt":1620.00,"samt":1620.00,"csamt":0.00},{"num":4,"hsn_sc":"996713","desc":"BL CHARGES INCOME","uqc":"OTH","qty":0,"val":9440.00,"txval":8000.00,"iamt":990.00,"camt":225.00,"samt":225.00,"csamt":0.00},{"num":5,"hsn_sc":"996711","desc":"MUC INCOME","uqc":"OTH","qty":0,"val":12832.50,"txval":10875.00,"iamt":1879.20,"camt":39.15,"samt":39.15,"csamt":0.00},{"num":6,"hsn_sc":"996711","desc":"IGM CHARGES","uqc":"OTH","qty":0,"val":1947.00,"txval":1650.00,"iamt":297.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":7,"hsn_sc":"996711","desc":"Handling Charges INCOME","uqc":"OTH","qty":0,"val":57761.00,"txval":48950.00,"iamt":8811.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":8,"hsn_sc":"996711","desc":"Container Storage","uqc":"OTH","qty":0,"val":8962.10,"txval":7595.00,"iamt":1367.10,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":9,"hsn_sc":"996711","desc":"Repair Cleaning Charges","uqc":"OTH","qty":0,"val":2790.70,"txval":2365.00,"iamt":425.70,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":10,"hsn_sc":"996711","desc":"SURVEY CHARGES","uqc":"OTH","qty":0,"val":5315.90,"txval":4505.00,"iamt":810.90,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":11,"hsn_sc":"996711","desc":"WASHING","uqc":"OTH","qty":0,"val":7245.20,"txval":6140.00,"iamt":1105.20,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":12,"hsn_sc":"996711","desc":"LOLO CHARGES","uqc":"OTH","qty":0,"val":7522.50,"txval":6375.00,"iamt":1147.50,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":13,"hsn_sc":"996711","desc":"IT Bond EGM Filling","uqc":"OTH","qty":0,"val":708.00,"txval":600.00,"iamt":108.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":14,"hsn_sc":"996521","desc":"Ocean Freight Slot Non Tax","uqc":"OTH","qty":0,"val":189321.00,"txval":189321.00,"iamt":0.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":15,"hsn_sc":"996711","desc":"Additional Charges Income","uqc":"OTH","qty":0,"val":40276.94,"txval":34133.00,"iamt":6143.94,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":16,"hsn_sc":"996711","desc":"SSR Charges","uqc":"OTH","qty":0,"val":1180.00,"txval":1000.00,"iamt":180.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":17,"hsn_sc":"996711","desc":"FEEDER CHARGES","uqc":"OTH","qty":0,"val":2950.00,"txval":2500.00,"iamt":450.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":18,"hsn_sc":"996719","desc":"DO CHARGES","uqc":"OTH","qty":0,"val":25960.00,"txval":22000.00,"iamt":3960.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":19,"hsn_sc":"996719","desc":"DOCUMENTATION CHARGES","uqc":"OTH","qty":0,"val":9440.00,"txval":8000.00,"iamt":1440.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":20,"hsn_sc":"996711","desc":"M R Charges Income","uqc":"OTH","qty":0,"val":13570.00,"txval":11500.00,"iamt":2070.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":21,"hsn_sc":"996711","desc":"Equipment Facilitation Charges","uqc":"OTH","qty":0,"val":11210.00,"txval":9500.00,"iamt":1710.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":22,"hsn_sc":"996711","desc":"HBL Manifest","uqc":"OTH","qty":0,"val":5900.00,"txval":5000.00,"iamt":900.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":23,"hsn_sc":"996711","desc":"CIC INCOME","uqc":"OTH","qty":0,"val":19035.76,"txval":16132.00,"iamt":2903.76,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":24,"hsn_sc":"996799","desc":"BL SURRENDER CHARGES INCOME","uqc":"OTH","qty":0,"val":2360.00,"txval":2000.00,"iamt":360.00,"camt":0.00,"samt":0.00,"csamt":0.00},{"num":25,"hsn_sc":"99","desc":"TRANSPORTATION CHARGES INCOME","uqc":"OTH","qty":0,"val":11504.00,"txval":11504.00,"iamt":0.00,"camt":0.00,"samt":0.00,"csamt":0.00}]}}
What I have tried:
This is comes under Seperate Class file
class Voureg { public string gstin = ""; public string fp= ""; public string gt = ""; public string cur_gt = ""; public List<b2blist> ctin { get; set; } public class b2blist { public string ctin = ""; public invlist inv { get; set; } } public class invlist { public string inum = ""; public string idt = ""; public double val = 0; public int pos = 0; public string rchrg = ""; public string inv_type = ""; } }
This Comes under in Button Click event
iFACTTouch.FAForms.Voureg strjson = new FAForms.Voureg();
DataSet Dtclientgst = new DataSet();
DataTable dtclienttab = new DataTable();
dtcompgst = bobj.GetCompDetailsfrombranchid(Convert.ToInt32(Session["Loginbranchid"].ToString()));
Dtclientgst = bobj.GetCustomergstinbranchwiseJson();
if (Dtclientgst.Tables.Count > 0 )
{
dtclienttab = Dtclientgst.Tables[0];
}
if (dtcompgst.Rows.Count > 0)
{
strjson.gstin = dtcompgst.Rows[0]["gstin"].ToString();
strjson.fp = "012019";
strjson.gt = "0.00";
strjson.cur_gt = "0.00";
//j.b2b = "";
if (dtclienttab.Rows.Count > 1)
{
for (int i = 0; i < dtclienttab.Rows.Count -1; i++)
{
if (clientgstin == "")
{
clientgstin = dtclienttab.Rows[i]["ctin"].ToString();
}
else
{
clientgstin = clientgstin + "/" + dtclienttab.Rows[i]["ctin"].ToString();
}
}
}
string[] gstin = clientgstin.Split('/');
for (int k = 0; k < gstin.Length; k++)
{
strjson.ctin.Add (gstin[k]);
}
}
string JSONResult = Newtonsoft.Json.JsonConvert.SerializeObject(strjson);
string path = @"D:\json\test.json";
if (File.Exists(path))
{
File.Delete(path);
using (var tw = new StreamWriter(path, true))
{
tw.WriteLine(JSONResult.ToString());
tw.Close();
}
}
else if (!File.Exists(path))
{
using (var tw = new StreamWriter(path, true))
{
tw.WriteLine(JSONResult.ToString());
tw.Close();
}
}
}
}
这篇关于如何编写c#.net编码来创建json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!