Handling empty text nodes
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONNormalizedNodeStreamWriter.java
index 90fa0d40218c28165ee9d8c44ec8f61596b3f171..c4aa72355746cce6eb786868e928dce97497f365 100644 (file)
@@ -276,10 +276,9 @@ public final class JSONNormalizedNodeStreamWriter implements NormalizedNodeStrea
 
     private void writeXmlValue(final Node node) throws IOException {
         Text firstChild = getFirstChildText(node);
+        String childNodeText = firstChild != null ? firstChild.getWholeText() : "";
+        childNodeText = childNodeText != null ? childNodeText.trim() : "";
 
-        final String childNodeText = firstChild!=null
-                ? (firstChild.getWholeText()!=null ? firstChild.getWholeText().trim() : null)
-                : "null";
         if (NUMBER_PATTERN.matcher(childNodeText).matches()) {
             writer.value(parseNumber(childNodeText));
             return;