Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
{"cancellationCharge":"35.00","refundAmount":"315.00","tin":"*****"}


I want the refundamount to be saved in string.

What I have tried:

Please provide the solution ASAP
Posted
Updated 1-Jun-16 4:36am
Comments
Rob Philpott 1-Jun-16 10:33am    
What is that, JSON? If so I'd expect the numbers not to be quoted. Do you know how to parse JSON using something like JSON.NET?

1 solution

This looks like JSON data try the below instead of comma separated string.
C#
var data = '{"cancellationCharge":"35.00","refundAmount":"315.00","tin":"*****"}';
      var json = JSON.parse(data);
      var cancellationCharge = json.cancellationCharge; // 35.00
      var refundAmount = json.refundAmount; //315.00
      var tin = json.tin; // *****


by using Comma separated:
JavaScript
var data = '{"cancellationCharge":"35.00","refundAmount":"315.00","tin":"*****"}';
      var items = data.split(',');
      var cancellationCharge = items[0].split(':')[1];
      var refundAmount = items[1].split(':')[1];
      var tin = items[2].split(':')[1];
 
Share this answer
 
Comments
siva Prasad Paruchuri 1-Jun-16 10:43am    
Thanks a Lot...
Karthik_Mahalingam 1-Jun-16 10:48am    
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900