@@ -15,7 +15,8 @@ class JsonProcessor implements Processor {
1515 let value = resMap [ key ] ;
1616 const isBool = typeof value === "boolean" ;
1717 const isNumber = this . isNumber ( value ) ;
18- value = value . toString ( ) ;
18+ const isNull = value === null ;
19+ value = ( isNull ) ? "" : value . toString ( ) ;
1920
2021 const id : string = idGenerator . generateId ( value , { } , ctx ) ;
2122 const segment : Segment = {
@@ -48,7 +49,9 @@ class JsonProcessor implements Processor {
4849 ? { isBool : true }
4950 : isNumber
5051 ? { isNumber : true }
51- : { } ,
52+ : isNull
53+ ? { isNull : true }
54+ : { } ,
5255 children : [
5356 {
5457 "type" : "segment" ,
@@ -89,15 +92,23 @@ class JsonProcessor implements Processor {
8992 segmentsMap [ segment . id ] = segment ;
9093 } ) ;
9194
92- const rows : { key : string , value : string | boolean | number } [ ] = [ ] ;
95+ const rows : { key : string , value : string | boolean | number | null } [ ] = [ ] ;
9396
9497 visitParents ( data . layout , { tagName : "tr" } , ( row : any ) => {
9598 const key = row . children [ 0 ] . children [ 0 ] . value
9699 const isBool = row . children [ 1 ] ?. properties ?. isBool ;
97100 const isNumber = row . children [ 1 ] ?. properties ?. isNumber ;
98-
99- const value = segmentsMap [ row . children [ 1 ] . children [ 0 ] . id ] . text ;
100- rows . push ( { key, value : isBool ? ( value === "true" ) : isNumber ? Number ( value ) : value } ) ;
101+ const isNull = row . children [ 1 ] ?. properties ?. isNull ;
102+
103+ const item = segmentsMap [ row . children [ 1 ] . children [ 0 ] . id ] . text ;
104+ const value = isBool
105+ ? ( item === "true" )
106+ : isNumber
107+ ? Number ( item )
108+ : isNull
109+ ? null
110+ : item ;
111+ rows . push ( { key, value} ) ;
101112 } ) ;
102113
103114 return JSON . stringify ( this . _convertMapToJson ( rows ) , null , 2 ) ;
@@ -132,7 +143,7 @@ class JsonProcessor implements Processor {
132143 return result ;
133144 }
134145
135- protected _convertMapToJson ( rows : { key : string , value : string | boolean | number } [ ] ) {
146+ protected _convertMapToJson ( rows : { key : string , value : string | boolean | number | null } [ ] ) {
136147 const result = { } ;
137148
138149 rows . forEach ( row => {
@@ -155,7 +166,7 @@ class JsonProcessor implements Processor {
155166 }
156167
157168 const lastKey : string = keys [ keys . length - 1 ] ;
158- const lastValue : string | boolean | number = value ;
169+ const lastValue : string | boolean | number | null = value ;
159170
160171 if ( Number . isInteger ( Number ( lastKey ) ) && typeof lastValue === "string" ) {
161172 currentObj . push ( { [ lastValue ?. split ( ':' ) [ 0 ] . trim ( ) ] : lastValue . split ( ':' ) [ 1 ] . trim ( ) } ) ;
0 commit comments