I have a console application which receives data from a website
The format of the returned JSon data which is stored in a string is:
{ "echo_req":{ "subscribe":1,"transaction":1},"msg_type":"transac tion","transaction":{ "action":"buy","amount":"-250.0000","balance":"530800.61","contract_id":"108 32430388","currency":"USD","date_expiry":147824233 5," display_name":"Volatility 10 Index","id":"de7cc6e6-218c-86a5-805f-093c1176f605","longcode":"Win payout if Volatility 10 Index is strictly lower than entry spot at 15 minutes after contract start time.","symbol":"R_10","transaction_id":"215802164 88","transaction_time":1478241435}}
How can I make the Json into separate variables or class object so that i can save them in the database.
To further add I found a json2csharp. I am more interested in saving the data in the Transaction class but don't know what to do from here:
- publicclassEchoReq
- {
- publicint subscribe {get;set;}
- publicint transaction {get;set;}
- }
- publicclassTransaction
- {
- publicstring action {get;set;}
- publicstring amount {get;set;}
- publicstring balance {get;set;}
- publicstring contract_id {get;set;}
- publicstring currency {get;set;}
- publicint date_expiry {get;set;}
- publicstring display_name {get;set;}
- publicstring id {get;set;}
- publicstring longcode {get;set;}
- publicstring symbol {get;set;}
- publicstring transaction_id {get;set;}
- publicint transaction_time {get;set;}
- }
- publicclassRootObject
- {
- publicEchoReq echo_req {get;set;}
- publicstring msg_type {get;set;}
- publicTransaction transaction {get;set;}
- }
Amit GuptaPosted Nov 4, 2016, 1:13 PM
Rajeev PunhaniPosted Nov 4, 2016, 2:05 PM
If the above solution is helpful then,accept the answer.
Ravi PatelPosted Nov 4, 2016, 5:31 AM
- "echo_req":{
- "msg_type":"transac tion",
- "transaction":{
}- "subscribe":1,
- "transaction":1
},- "action":"buy",
- "amount":"-250.0000",
- "balance":"530800.61",
- "contract_id":"108 32430388",
- "currency":"USD",
- "date_expiry":"1478242335",
- "display_name":"Volatility 10 Index",
- "id":"de7cc6e6-218c-86a5-805f-093c1176f605",
- "longcode":"Win payout if Volatility 10 Index is strictly lower than entry spot at 15 minutes after contract start time.",
- "symbol":"R_10",
- "transaction_id":"215802164 88",
- "transaction_time":1478241435
}Prakash KumarPosted Nov 4, 2016, 4:30 AM