@@ -145,9 +145,14 @@ export function parseJsonContent(content) {
145145 if ( Array . isArray ( obj ) ) return obj . map ( processJsonObject ) ;
146146
147147 return Object . keys ( obj ) . reduce ( ( result , key ) => {
148- const newKey = key . replace ( / _ / g, "" ) ;
149148 let value = obj [ key ] ;
150149
150+ if ( value === null || value === undefined ) {
151+ return result ;
152+ }
153+
154+ const newKey = key . replace ( / _ / g, "" ) ;
155+
151156 // Check if this is a value object with only a 'value' property and flatten
152157 if (
153158 value !== null &&
@@ -157,9 +162,18 @@ export function parseJsonContent(content) {
157162 "value" in value
158163 ) {
159164 value = value . value ;
165+
166+ if ( value === null || value === undefined ) {
167+ return result ;
168+ }
160169 } else if ( typeof value === "object" && value !== null ) {
161170 // Recursively process nested objects
162171 value = processJsonObject ( value ) ;
172+
173+ // Skip empty objects (those with no properties after processing)
174+ if ( typeof value === "object" && ! Array . isArray ( value ) && Object . keys ( value ) . length === 0 ) {
175+ return result ;
176+ }
163177 }
164178
165179 result [ newKey ] = value ;
@@ -170,7 +184,7 @@ export function parseJsonContent(content) {
170184 try {
171185 const parsed = JSON . parse ( content ) ;
172186 const processedData = processJsonObject ( parsed ) ;
173- log ( "Processed JSON data: removed underscores and flattened value objects" ) ;
187+ log ( "Processed JSON data: removed underscores, flattened value objects, and pruned null/undefined fields " ) ;
174188 return sortObjectKeys ( processedData ) ;
175189 } catch ( error ) {
176190 log ( "Initial JSON parsing failed, attempting to wrap in array" ) ;
0 commit comments