我有这样的json字符串:
[
{"COMPLIANCE_ID":"1/FIRST/US/191CC2/20160906/pW1WSpD/1","TOLERANCE":null,"WEIGHTED_ARR_LAST_SLP":"0.03801186624130076","SLIPPAGE_INTERVAL_VWAP_BPS":"10.2711","ROOT_ORDER_ID":"735422197553491","ENTERING_TRADER":"duffy_dma2","SECURITY_ID":"EOG.N","ARRIVAL_MID_PX":"93.6100","WEIGHTED_ARR_SLP":"0.12323190317127024","AVG_PX":"93.6586","ORDER_CCY":"USD","LEAVES_QTY":"0","WEIGHT":"0.02372627566400397","INITIATING_TRADER":null,"PARTICIPATION_RATE":"0E-12","LOCAL_REF_END_TIME":"2016-09-06 06:00:27.775","WEIGHTED_IVWAP_SLP":"0.2436949499725512","NOTIONAL_USD":"477940","LIST_ID":null,"SYM":"EOG","LIQ_CONSUMPTION":"15.21","URGENCY":null,"SIDE":"Sell Short","ALGO":"Hydra","EXECUTING_TRADER":"duffy_dma2","EXEC_QTY":"5103","CL_ORD_ID":"7245294057012908344","LOCAL_REF_START_TIME":"2016-09-06 05:59:57.844","SLIPPAGE_END_LAST_ARR_LAST_BPS":"1.6021","ORD_STATUS":"Filled","IVWAP_PX":"93.5625","LIMIT_PX":"93.6100","ORDER_ID":"735422197553491","VOLUME_LIMIT":"0E-12","SLIPPAGE_ARR_MID_BPS":"5.1939","ORDER_QTY":"5103","CLIENT_ACRONYM":"PEAKM","EXECUTION_STYLE":"2"},{"COMPLIANCE_ID":"1/FIRST/US/191CC2/20160906/pW1PUxP/1","TOLERANCE":null,"WEIGHTED_ARR_LAST_SLP":"-0.046488357264395964","SLIPPAGE_INTERVAL_VWAP_BPS":"0.1625","ROOT_ORDER_ID":"73855219760798","ENTERING_TRADER":"duffy_dma2","SECURITY_ID":"MCD.N","ARRIVAL_MID_PX":"118.0950","WEIGHTED_ARR_SLP":"-0.0041198933937856425","AVG_PX":"118.0923","ORDER_CCY":"USD","LEAVES_QTY":"0","WEIGHT":"0.01830250285999841","INITIATING_TRADER":null,"PARTICIPATION_RATE":"0E-12","LOCAL_REF_END_TIME":"2016-09-06 05:32:24.895","WEIGHTED_IVWAP_SLP":"0.002974156714749742","NOTIONAL_USD":"368684","LIST_ID":null,"SYM":"MCD","LIQ_CONSUMPTION":"62.82","URGENCY":null,"SIDE":"Sell","ALGO":"Hydra","EXECUTING_TRADER":"duffy_dma2","EXEC_QTY":"3122","CL_ORD_ID":"7244573979975932119","LOCAL_REF_START_TIME":"2016-09-06 05:32:19.697","SLIPPAGE_END_LAST_ARR_LAST_BPS":"-2.5400","ORD_STATUS":"Filled","IVWAP_PX":"118.0904","LIMIT_PX":"117.9900","ORDER_ID":"73855219760798","VOLUME_LIMIT":"0E-12","SLIPPAGE_ARR_MID_BPS":"-0.2251","ORDER_QTY":"3122","CLIENT_ACRONYM":"PEAKM","EXECUTION_STYLE":"4"}]
我从js文件中的另一个文件中获取:
var jsondata = document.getElementById("jsonArray").value;
如何从jsondata中提取json元素到这样的变量:
RefData.COMPLIANCE_ID = [
"1/FIRST/US/191CC2/20160906/pW1WSpD/1", "1/FIRST/US/191CC2/20160906/pW1PUxP/1"
];
等。
答案 0 :(得分:0)
试试这个
var json = JSON.parse(jsondata );
var compliance_id = json["COMPLIANCE_ID"];
答案 1 :(得分:0)
我认为这会奏效。
var Foo = function () {
$('body').off('click', '.btn');
$('body').on('click', '.btn', this.update.bind(this));
};
此时RefData应该具有COMPLIANCE_ID,TOLERANCE,WEIGHTED_ARR_LAST_SLP等属性。这些都是具有2个值的数组。