code: private void toJSON(JSONEmitter json) {
          switch (m_type) {
          case ARRAY:
              json.startArray(m_name);
              if (m_children != null) {
                  for (UNode childNode : m_children) {
                      if (childNode.isMap()) {
                          json.startObject();
                          childNode.toJSON(json);
                          json.endObject();
                      } else {
                          childNode.toJSON(json);
                      }
                  }
              }
              json.endArray();
              break;
              
          case MAP:
              // Return map child modes in name order.
              json.startGroup(m_name);
              if (m_childNodeMap != null) {
                  assert m_childNodeMap.size() == m_children.size();
                  for (UNode childNode : m_childNodeMap.values()) {
                      childNode.toJSON(json);
                  }
              }
              json.endGroup();
              break;
              
          case VALUE:
              if (m_bAltFormat && m_tagName != null) {
                  // Generate as "<tag>: {"<name>": "<value>"}
                  json.startGroup(m_tagName);
                  json.addValue(m_name, m_value);
                  json.endGroup();
              } else if (m_parent != null && m_parent.isArray()) {
                  if (m_name.equals("value")) {
                      // nameless node: "<value>"
                      json.addValue(m_value);
                  } else {
                      // value as an object: {"name": "value"}
                      json.addObject(m_name, m_value);
                  }
              } else {
                  // Simple case: "<name>": "<value>"
                  json.addValue(m_name, m_value);
              }
              break;
              
          default:
              assert false : "Unknown NodeType: " + m_type;
          }
      }
docs: Add the appropriate JSON syntax for this UNode to the given JSONEmitter.