@@ -21,10 +21,10 @@ var js2xmlparser = require("../lib/main");
2121/**
2222 * This example demonstrates a very simple usage of js2xmlparser.
2323 */
24- var example1 = function ( ) {
24+ var example1 = function ( ) {
2525 var obj = {
26- " firstName" : "John" ,
27- " lastName" : "Smith"
26+ firstName : "John" ,
27+ lastName : "Smith" ,
2828 } ;
2929 console . log ( js2xmlparser . parse ( "person" , obj ) ) ;
3030 console . log ( ) ;
@@ -34,44 +34,44 @@ example1();
3434/**
3535 * This example demonstrates a more complex usage of j2xmlparser.
3636 */
37- var example2 = function ( ) {
37+ var example2 = function ( ) {
3838 var obj = {
3939 "@" : {
40- " type" : "natural"
40+ type : "natural" ,
4141 } ,
42- " firstName" : "John" ,
43- " lastName" : "Smith" ,
44- " dateOfBirth" : new Date ( 1964 , 7 , 26 ) ,
45- " address" : {
42+ firstName : "John" ,
43+ lastName : "Smith" ,
44+ dateOfBirth : new Date ( 1964 , 7 , 26 ) ,
45+ address : {
4646 "@" : {
47- " type" : "home"
47+ type : "home" ,
4848 } ,
49- " streetAddress" : "3212 22nd St" ,
50- " city" : "Chicago" ,
51- " state" : "Illinois" ,
52- " zip" : 10000
49+ streetAddress : "3212 22nd St" ,
50+ city : "Chicago" ,
51+ state : "Illinois" ,
52+ zip : 10000 ,
5353 } ,
54- " phone" : [
54+ phone : [
5555 {
5656 "@" : {
57- " type" : "home"
57+ type : "home" ,
5858 } ,
59- "#" : "123-555-4567"
59+ "#" : "123-555-4567" ,
6060 } ,
6161 {
6262 "@" : {
63- " type" : "cell"
63+ type : "cell" ,
6464 } ,
65- "#" : "890-555-1234"
65+ "#" : "890-555-1234" ,
6666 } ,
6767 {
6868 "@" : {
69- " type" : "work"
69+ type : "work" ,
7070 } ,
71- "#" : "567-555-8901"
72- }
71+ "#" : "567-555-8901" ,
72+ } ,
7373 ] ,
74- " email" : "john@smith.com"
74+ email : "john@smith.com" ,
7575 } ;
7676 console . log ( js2xmlparser . parse ( "person" , obj ) ) ;
7777 console . log ( ) ;
@@ -81,107 +81,107 @@ example2();
8181/**
8282 * This example demonstrates some of js2xmlparser's options.
8383 */
84- var example3 = function ( ) {
84+ var example3 = function ( ) {
8585 var options = {
8686 aliasString : "exAlias" ,
8787 attributeString : "exAttr" ,
88- cdataKeys : [
89- "exCdata" ,
90- "exCdata2"
91- ] ,
88+ cdataKeys : [ "exCdata" , "exCdata2" ] ,
9289 declaration : {
9390 include : true ,
9491 encoding : "UTF-16" ,
9592 standalone : "yes" ,
96- version : "1.1"
93+ version : "1.1" ,
9794 } ,
9895 dtd : {
9996 include : true ,
10097 name : "exName" ,
10198 sysId : "exSysId" ,
102- pubId : "exPubId"
99+ pubId : "exPubId" ,
103100 } ,
104101 format : {
105102 doubleQuotes : true ,
106103 indent : "\t" ,
107104 newline : "\r\n" ,
108- pretty : true
105+ pretty : true ,
109106 } ,
110107 typeHandlers : {
111- "[object Number]" : function ( value ) {
108+ "[object Number]" : function ( value ) {
112109 return value + 17 ;
113- }
110+ } ,
114111 } ,
115112 valueString : "exVal" ,
116113 wrapHandlers : {
117- " exArr" : function ( ) {
114+ exArr : function ( ) {
118115 return "exArrInner" ;
119- }
120- }
116+ } ,
117+ } ,
121118 } ;
122119
123120 var obj = {
124- " ex1" : "ex2" ,
125- " exVal_1" : 123 ,
126- " ex3" : [ "ex4" , "ex5" ] ,
127- " ex6" : {
128- " exAttr_1" : {
129- " ex7" : "ex8" ,
130- " ex9" : "ex10"
121+ ex1 : "ex2" ,
122+ exVal_1 : 123 ,
123+ ex3 : [ "ex4" , "ex5" ] ,
124+ ex6 : {
125+ exAttr_1 : {
126+ ex7 : "ex8" ,
127+ ex9 : "ex10" ,
131128 } ,
132- " ex11" : "ex12" ,
133- " ex13" : {
134- " ex14" : "ex15"
129+ ex11 : "ex12" ,
130+ ex13 : {
131+ ex14 : "ex15" ,
135132 } ,
136- " ex16" : [
133+ ex16 : [
137134 "ex17" ,
138135 {
139- " ex18" : "ex19"
140- }
136+ ex18 : "ex19" ,
137+ } ,
141138 ] ,
142- " exArr" : [
139+ exArr : [
143140 "ex20" ,
144141 {
145- " ex21" : "ex22"
146- }
142+ ex21 : "ex22" ,
143+ } ,
147144 ] ,
148- " exAttr_2" : {
149- " ex23" : "ex24" ,
150- " ex25" : "ex26"
151- }
145+ exAttr_2 : {
146+ ex23 : "ex24" ,
147+ ex25 : "ex26" ,
148+ } ,
152149 } ,
153- "exVal_2" : "ex27" ,
154- "ex28" : [
155- "ex29" ,
156- "ex30"
157- ] ,
158- "ex31" : true ,
159- "ex32" : undefined ,
160- "ex33" : null ,
161- "ex34" : 3.4 ,
162- "ex35" : function ( ) {
150+ exVal_2 : "ex27" ,
151+ ex28 : [ "ex29" , "ex30" ] ,
152+ ex31 : true ,
153+ ex32 : undefined ,
154+ ex33 : null ,
155+ ex34 : 3.4 ,
156+ ex35 : function ( ) {
163157 return "ex36" ;
164158 } ,
165- " ex37" : "i<j&" ,
166- " exCdata" : "i<j&" ,
167- " exCdata2" : "ddd" ,
168- " ex38" : {
169- " exAlias" : "ex39" ,
170- " ex40" : "ex41"
159+ ex37 : "i<j&" ,
160+ exCdata : "i<j&" ,
161+ exCdata2 : "ddd" ,
162+ ex38 : {
163+ exAlias : "ex39" ,
164+ ex40 : "ex41" ,
171165 } ,
172- "ex42" : [ "ex43" , "ex44" , "ex45" , [ "ex46" , "ex47" ] ,
173- new Set ( [ "ex48" , "ex49" ] ) ] ,
174- "ex50" : new Map ( [
166+ ex42 : [
167+ "ex43" ,
168+ "ex44" ,
169+ "ex45" ,
170+ [ "ex46" , "ex47" ] ,
171+ new Set ( [ "ex48" , "ex49" ] ) ,
172+ ] ,
173+ ex50 : new Map ( [
175174 [ "ex51" , "ex52" ] ,
176175 [ "exVal_1" , "ex53" ] ,
177176 [ "ex54" , "ex55" ] ,
178- [ "exAttr_1" ,
177+ [
178+ "exAttr_1" ,
179179 {
180- " ex56" : "ex57" ,
181- " ex58" : "ex59"
182- }
183- ]
184- ] )
180+ ex56 : "ex57" ,
181+ ex58 : "ex59" ,
182+ } ,
183+ ] ,
184+ ] ) ,
185185 } ;
186186 console . log ( js2xmlparser . parse ( "ex0" , obj , options ) ) ;
187187 console . log ( ) ;
0 commit comments