File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 3232 "homepage" : " https://github.com/tencentyun/cos-nodejs-sdk-v5#readme" ,
3333 "dependencies" : {
3434 "conf" : " ^9.0.0" ,
35+ "fast-xml-parser" : " ^4.2.2" ,
3536 "mime-types" : " ^2.1.24" ,
36- "request" : " ^2.88.2" ,
37- "xml2js" : " ^0.5.0"
37+ "request" : " ^2.88.2"
3838 },
3939 "devDependencies" : {
4040 "@types/node" : " ^14.14.20" ,
Original file line number Diff line number Diff line change 22
33var fs = require ( 'fs' ) ;
44var crypto = require ( 'crypto' ) ;
5- var xml2js = require ( 'xml2js ' ) ;
6- var xmlParser = new xml2js . Parser ( { explicitArray : false , ignoreAttrs : true } ) ;
7- var xmlBuilder = new xml2js . Builder ( ) ;
5+ var { XMLParser , XMLBuilder } = require ( 'fast-xml-parser ' ) ;
6+ var xmlParser = new XMLParser ( { ignoreAttributes : true } ) ;
7+ var xmlBuilder = new XMLBuilder ( ) ;
88
99function camSafeUrlEncode ( str ) {
1010 return encodeURIComponent ( str )
@@ -187,17 +187,14 @@ var clearKey = function (obj) {
187187
188188// XML 对象转 JSON 对象
189189var xml2json = function ( bodyStr ) {
190- var d = { } ;
191- xmlParser . parseString ( bodyStr , function ( err , result ) {
192- d = result ;
193- } ) ;
190+ var d = xmlParser . parse ( bodyStr ) ;
194191
195192 return d ;
196193} ;
197194
198195// JSON 对象转 XML 对象
199196var json2xml = function ( json ) {
200- var xml = xmlBuilder . buildObject ( json ) ;
197+ var xml = xmlBuilder . build ( json ) ;
201198 return xml ;
202199} ;
203200
You can’t perform that action at this time.
0 commit comments