本文介绍了从逗号分隔的字符串中获取项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{"cancellationCharge":"35.00","refundAmount":"315.00","tin":"*****"}





我希望将退款保存在字符串中。



我尝试了什么:



请提供解决方案ASAP



I want the refundamount to be saved in string.

What I have tried:

Please provide the solution ASAP

推荐答案

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:

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];


这篇关于从逗号分隔的字符串中获取项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 18:48