使用ScriptEngineManager解析json

Posted yangykaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用ScriptEngineManager解析json相关的知识,希望对你有一定的参考价值。

使用ScriptEngineManager能够解析比較复杂的json串,应用比較方便,可是效率不敢说,由于这种方法相当于执行了一次js。会占资源,

代码例如以下:

try {
							String mdskipJson = "";
							ScriptEngineManager manager = new ScriptEngineManager();  
						    ScriptEngine engine = manager.getEngineByName("js");
						    String  s="  var o = " + mdskipJson + ";";
						    try {
						    	 engine.eval(s+" var promotePrice=\"\"; var price=\"\"; var objs=o.defaultModel.itemPriceResultDO.priceInfo;for(var e in objs){price=objs[e].price;promotePrice=objs[e].promotionList[0].price+\"   \";break;}");
						         Object sellCount = engine.eval(s+" o.defaultModel.sellCountDO.sellCount");//月销量
						         Object price = engine.get("price");//原价
						         Object promotePrice = engine.get("promotePrice");//促销价
						         System.out.println("---------------------------");
						         System.out.println(price);
						         System.out.println(sellCount);
						         System.out.println(promotePrice);
						    } catch (Exception e) {
						        e.printStackTrace();
						    } ;
						} catch (Exception e) {
							e.printStackTrace();
						}


</pre><pre>

json串例如以下:

setMdskip({'isSuccess':true,'defaultModel':{'buyerRestrictInfoDO':{'amountRestrictInfoMap':{}},'deliveryDO':{'areaId':320500,'deliveryAddress':'浙江杭州','deliverySkuMap':{'34291470880':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470881':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470882':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470883':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470884':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470885':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470886':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470887':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470888':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470889':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470890':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470891':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470892':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470893':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470894':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470895':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470896':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'34291470897':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}],'default':[{'money':null,'name':null,'postage':'快递: 6.00 EMS: 12.00 ','postageFree':false,'serviceLinkText':null,'serviceLinkUrl':null,'signText':null,'tagImage':null,'tips':null,'type':0}]},'destination':'苏州市','hasHomeDeliveryService':false,'otherServiceList':[]},'detailPageTipsDO':{'campaignText':null,'hideIcons':false,'icons':null,'itemTitle':null,'jhs99':false,'juOpenTimeStr':null,'minicartSurprise':0,'priceDisplayType':4,'showDou12CornerIcon':false,'warmUpIcons':null,'warmingUpHintText':null},'doubleEleven2014':{'doubleElevenItem':false,'showAtmosphere':false,'showRightRecommendedArea':false,'step':0},'gatewayDO':{'changeLocationGateway':{'i_channel':null,'queryDelivery':true,'queryProm':false},'trade':{'addToBuyNow':{},'addToCart':{}}},'inventoryDO':{'hidden':false,'icTotalQuantity':266,'skuQuantity':{34291470880:{'quantity':0,'totalQuantity':0,'type':1},34291470881:{'quantity':1,'totalQuantity':1,'type':1},34291470882:{'quantity':2,'totalQuantity':2,'type':1},34291470883:{'quantity':64,'totalQuantity':64,'type':1},34291470884:{'quantity':15,'totalQuantity':15,'type':1},34291470885:{'quantity':0,'totalQuantity':0,'type':1},34291470886:{'quantity':0,'totalQuantity':0,'type':1},34291470887:{'quantity':0,'totalQuantity':0,'type':1},34291470888:{'quantity':0,'totalQuantity':0,'type':1},34291470889:{'quantity':0,'totalQuantity':0,'type':1},34291470890:{'quantity':2,'totalQuantity':2,'type':1},34291470891:{'quantity':0,'totalQuantity':0,'type':1},34291470892:{'quantity':0,'totalQuantity':0,'type':1},34291470893:{'quantity':0,'totalQuantity':0,'type':1},34291470894:{'quantity':95,'totalQuantity':95,'type':1},34291470895:{'quantity':87,'totalQuantity':87,'type':1},34291470896:{'quantity':0,'totalQuantity':0,'type':1},34291470897:{'quantity':0,'totalQuantity':0,'type':1}},'success':true,'totalQuantity':266,'type':1},'itemPriceResultDO':{'areaId':320500,'campaignInfo':null,'duo11Item':false,'duo11Stage':0,'extraPromHrefText':null,'extraPromIcon':null,'extraPromShowRealPrice':false,'halfOffItem':false,'hasDPromotion':false,'hasMobileProm':false,'hideMeal':false,'priceInfo':{'34291470880':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470881':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470882':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470883':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470884':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470885':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470886':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470887':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470888':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470889':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470890':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470891':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470892':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470893':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470894':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470895':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470896':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null},'34291470897':{'areaSold':true,'encryptDES':null,'localCurrencySymbol':null,'localReferencePrice':null,'price':'399.00','promotionList':[{'add':null,'amountPromLimit':0,'amountRestriction':'','basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':1414724854000,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':3,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'219.90','promText':null,'promType':'normal','start':false,'startTime':1393559627000,'status':2,'type':'春秋促销','typeUrl':null},{'add':null,'amountPromLimit':0,'amountRestriction':null,'basePriceType':'IcPrice','buyerAmountRestriction':null,'canBuyCouponNum':0,'channelCode':null,'endTime':null,'extraPromLocalReferencePrice':null,'extraPromPrice':null,'extraPromText':null,'extraPromTextType':0,'extraPromType':0,'gift':null,'limitProm':false,'limitTime':null,'limitTimeUTC':null,'localReferencePrice':null,'orderAmountRestriction':null,'price':'379.05','promText':'登录后确认是否享有此优惠','promType':'normal','start':false,'startTime':null,'status':2,'type':'店铺vip','typeUrl':null}],'suggestivePromotionList':null,'tagPrice':null,'wrtInfo':null}},'promType':null,'queryProm':false,'taojinbiForHK':null,'tmallShopProm':[{'campaignId':51794010,'campaignName':'做不一样的自己','campaignUrl':'http://marketing.tmall.com/home/tsp/page.htm?id=51794010_61127277','endTime':'1414771199000','participateType':1,'promPlan':[{'msg':'满179元,享包邮'},{'msg':'满200元,享包邮,送20元优惠券'},{'msg':'满300元,享包邮,送50元优惠券'},{'msg':'满400元,享包邮,送100元优惠券'},{'detailMsg':[{'method':{'logistics':{'exclusion':['710000','810000','820000','990100'],'exclusionName':['台湾','香港','澳门','海外'],'selected':true},'logisticsExclusion':['710000','810000','820000','990100'],'logisticsExclusionName':['台湾','香港','澳门','海外'],'man':'179','selectMusicPack':false,'selectedDiscount':false,'selectedEbook':false,'selectedGift':false,'selectedGiftPool':false,'selectedLogistics':true,'selectedShopCoupon':false,'shopCouponValid':false},'promotionLevel':1,'quantity':'179'},{'method':{'logistics':{'exclusion':['710000','810000','820000','990100'],'exclusionName':['台湾','香港','澳门','海外'],'selected':true},'logisticsExclusion':['710000','810000','820000','990100'],'logisticsExclusionName':['台湾','香港','澳门','海外'],'man':'200','selectMusicPack':false,'selectedDiscount':false,'selectedEbook':false,'selectedGift':false,'selectedGiftPool':false,'selectedLogistics':true,'selectedShopCoupon':true,'shopCoupon':{'from':'2014-11-11 00:00:00','price':'20','promotionId':157520461,'selected':true,'startFee':0,'to':'2014-11-30 23:59:59'},'shopCouponFrom':'2014-11-11 00:00:00','shopCouponPrice':'20','shopCouponPromotionId':157520461,'shopCouponTo':'2014-11-30 23:59:59','shopCouponValid':false},'promotionLevel':2,'quantity':'200'},{'method':{'logistics':{'exclusion':['710000','810000','820000','990100'],'exclusionName':['台湾','香港','澳门','海外'],'selected':true},'logisticsExclusion':['710000','810000','820000','990100'],'logisticsExclusionName':['台湾','香港','澳门','海外'],'man':'300','selectMusicPack':false,'selectedDiscount':false,'selectedEbook':false,'selectedGift':false,'selectedGiftPool':false,'selectedLogistics':true,'selectedShopCoupon':true,'shopCoupon':{'from':'2014-11-11 00:00:00','price':'50','promotionId':157652277,'selected':true,'startFee':0,'to':'2014-11-30 23:59:59'},'shopCouponFrom':'2014-11-11 00:00:00','shopCouponPrice':'50','shopCouponPromotionId':157652277,'shopCouponTo':'2014-11-30 23:59:59','shopCouponValid':false},'promotionLevel':3,'quantity':'300'},{'method':{'logistics':{'exclusion':['710000','810000','820000','990100'],'exclusionName':['台湾','香港','澳门','海外'],'selected':true},'logisticsExclusion':['710000','810000','820000','990100'],'logisticsExclusionName':['台湾','香港','澳门','海外'],'man':'400','selectMusicPack':false,'selectedDiscount':false,'selectedEbook':false,'selectedGift':false,'selectedGiftPool':false,'selectedLogistics':true,'selectedShopCoupon':true,'shopCoupon':{'from':'2014-11-11 00:00:00','price':'100','promotionId':157996267,'selected':true,'startFee':0,'to':'2014-11-30 23:59:59'},'shopCouponFrom':'2014-11-11 00:00:00','shopCouponPrice':'100','shopCouponPromotionId':157996267,'shopCouponTo':'2014-11-30 23:59:59','shopCouponValid':false},'promotionLevel':4,'quantity':'400'}],'msg':'','participateType':1,'unit':2}],'startTime':'1413936001000','warmUp':false}],'wanrentuanInfo':null},'memberRightDO':{'activeName':null,'activityId':null,'activityType':0,'level':0,'postageFree':false,'shopMember':false,'success':true,'time':1,'value':0.5},'miscDO':{'bucketId':17,'city':'苏州','cityId':320500,'redirectClientFlag':1,'region':'沧浪区','regionId':320502,'sellCountDown':0,'smartBannerFlag':'top','systemTime':'1414460040208','town':'','townId':0},'sellCountDO':{'cspuSellCountMap':{},'orderPersons':null,'sellCount':802},'specialServiceList':[],'tradeResult':{'cartEnable':true,'cartType':2,'discountText':null,'miniTmallCartEnable':true,'param':null,'sellCountDown':null,'tmallCarFinantialEnable':null,'tradeButtonUrl':null,'tradeDisableTypeEnum':null,'tradeEnable':true,'tradeTextLink':null,'tradeType':null},'userInfoDO':{'activeStatus':0,'juKeBuyerLogin':false,'loginUserType':'buyer','nicker':null,'userId':0}}})








以上是关于使用ScriptEngineManager解析json的主要内容,如果未能解决你的问题,请参考以下文章

在 java 中使用 ScriptEngineManager 定义变量

Powermock 不断为 ScriptEngineManager 抛出错误

java 判断一个字符串是不是是json格式

ScriptEngineManager

利用ScriptEngineManager实现简单的规则运算

Java执行js代码