Helper function for convert
@param {*} jsonElement
@return array representation of the corresponding jsonElement
544771
function convertHelper(jsonElement) {
  let elementArray = [];
  if (jsonElement.type === 'textnode') {
    return jsonElement.value;
  } else if (jsonElement.type === 'var' || jsonElement.type === 'derived') {
    elementArray = [jsonElement.type];
    elementArray.push([
      ['name', ['value', jsonElement.name]],
      ['value', ['value', jsonElement.value]]
    ]);
    elementArray.push([]);
  } else if (jsonElement.type === 'data') {
    elementArray = ['data'];
    elementArray.push([
      ['name', ['value', jsonElement.name]],
      ['source', ['value', jsonElement.source]]
    ]);
    elementArray.push([]);
  } else {
    elementArray.push(jsonElement.name);
    let propertiesArray = [];
    if ('properties' in jsonElement) {
      Object.keys(jsonElement.properties).forEach(key => {
        let propertyArray = [key];
        propertyArray.push([
          jsonElement.properties[key].type,
          jsonElement.properties[key].value
        ]);
        propertiesArray.push(propertyArray);
      });
    }
    elementArray.push(propertiesArray);
    if ('children' in jsonElement) {
      let childArray = [];
      jsonElement.children.forEach(children => {
        childArray.push(convertHelper(children));
      });
      elementArray.push(childArray);
    }
  }
  return elementArray;
}
489488
function convertObjectToJSON(data) {
      const delimiter = '_'
      let result = {}
      let arrays = {}
      data.forEach(item => {
        const value = item.value
        if (value !== '') {
          if (!item.name) return
          let name = item.name
          let nameParts = name.split(delimiter)
          let currResult = result
          for (let j = 0; j < nameParts.length; j++) {
            const namePart = nameParts[j]
            let arrName
            if (namePart.indexOf('[]') > -1 && j === nameParts.length - 1) {

              arrName = namePart.substr(0, namePart.indexOf('['))
              if (!currResult[arrName]) {
                currResult[arrName] = []
              }
              currResult[arrName].push(value)
            } else {
              if (namePart.indexOf('[') > -1) {
                arrName = namePart.substr(0, namePart.indexOf('['))
                const arrIdx = namePart.replace(/^[a-z]+\[|\]$/gi, '')
                if (!arrays[arrName]) {
                  arrays[arrName] = {}
                }
                if (!currResult[arrName]) {
                  currResult[arrName] = []
                }
                if (j === nameParts.length - 1) {
                  currResult[arrName].push(value)
                } else {
                  if (!arrays[arrName][arrIdx]) {
                    currResult[arrName].push({})
                    arrays[arrName][arrIdx] = currResult[arrName][currResult[arrName].length - 1]
                  }
                }
                currResult = arrays[arrName][arrIdx]
              } else {
                if (j < nameParts.length - 1) {
                  if (!currResult[namePart]) {
                    currResult[namePart] = {}
                  }
                  currResult = currResult[namePart]
                } else {
                  currResult[namePart] = value
                }
              }
            }
          }
        }
      })
      return result
    }
252303
def convert_loaded_json(js):
    
    if not isinstance(js, (Mapping, tuple, list)):
        return try_convert(js)
    try:
        return type(js)(convert_loaded_json(item) for item in js.iteritems())
    except:
        try:
            return type(js)(convert_loaded_json(item) for item in iter(js))
        except:
            return try_convert(js)
1242212
public static String convertJsonToYaml(Reader jsonReader) {
        try (Reader reader = jsonReader) {
            JsonNode json = new ObjectMapper().readTree(reader);

            return new YAMLMapper().writeValueAsString(json);
        } catch (IOException e) {
            throw new YamlRuntimeException(e);
        }
    }
879548
private JsonElement parsePrimitiveType(JsonSchema schema, JsonElement value)
      throws DataConversionException {

    if ((schema.isType(NULL) || schema.isNullable()) && value.isJsonNull()) {
      return JsonNull.INSTANCE;
    }

    if ((schema.isType(NULL) && !value.isJsonNull()) || (!schema.isType(NULL) && value.isJsonNull())) {
      throw new DataConversionException(
          "Type mismatch for " + value.toString() + " of type " + schema.getDataTypes().toString());
    }

    if (schema.isType(FIXED)) {
      int expectedSize = schema.getSizeOfFixedData();
      if (value.getAsString().length() == expectedSize) {
        return value;
      } else {
        throw new DataConversionException(
            "Fixed type value is not same as defined value expected fieldsCount: " + expectedSize);
      }
    } else {
      return value;
    }
  }
812721
private String convertToString(JsonNode jsonArrayNode) {

		StringBuilder strBuilder = new StringBuilder();
		Iterator<JsonNode> nodeIterator = jsonArrayNode.iterator();
		while (nodeIterator.hasNext()) {
			JsonNode jsonNode = (JsonNode) nodeIterator.next();
			strBuilder.append(jsonNode.asText());
			if (nodeIterator.hasNext()) {
				strBuilder.append(ARRAY_VALUE_SEPARATOR);
			}
		}
		return strBuilder.toString();
	}
188154
private static JSONArray _fromArray( Object[] array, JsonConfig jsonConfig ) {
      if( !addInstance( array ) ){
         try{
            return jsonConfig.getCycleDetectionStrategy()
                  .handleRepeatedReferenceAsArray( array );
         }catch( JSONException jsone ){
            removeInstance( array );
            fireErrorEvent( jsone, jsonConfig );
            throw jsone;
         }catch( RuntimeException e ){
            removeInstance( array );
            JSONException jsone = new JSONException( e );
            fireErrorEvent( jsone, jsonConfig );
            throw jsone;
         }
      }
      fireArrayStartEvent( jsonConfig );
      
      JSONArray jsonArray = new JSONArray();
      try{
         for( int i = 0; i < array.length; i++ ){
            Object element = array[i];
            jsonArray.addValue( element, jsonConfig );
            fireElementAddedEvent( i, jsonArray.get( i ), jsonConfig );
         }
      }catch( JSONException jsone ){
         removeInstance( array );
         fireErrorEvent( jsone, jsonConfig );
         throw jsone;
      }catch( RuntimeException e ){
         removeInstance( array );
         JSONException jsone = new JSONException( e );
         fireErrorEvent( jsone, jsonConfig );
         throw jsone;
      }

      removeInstance( array );
      fireArrayEndEvent( jsonConfig );
      return jsonArray;
   }
332714
function convertObject (schema, self) {
  var keys = Object.keys(schema);
  var ret = {};

  for (var i = 0; i < keys.length; ++i) {
    var key = keys[i];
    ret[key] = convertElement(schema[key], self);
  }

  return ret;
}
491969
function (jsonSource) {
		var json = null;

		try {
			json = JSON.parse(jsonSource);
		} catch (err) {
			json = jsonSource; // string
		}

		return json;
	}
839687
public static void parseJsonPathElements(Element validateElement, Map<String, Object> validateJsonPathExpressions) {
        List<?> jsonPathElements = DomUtils.getChildElementsByTagName(validateElement, "json-path");
        if (jsonPathElements.size() > 0) {
            for (Iterator<?> jsonPathIterator = jsonPathElements.iterator(); jsonPathIterator.hasNext();) {
                Element jsonPathElement = (Element) jsonPathIterator.next();
                String expression = jsonPathElement.getAttribute("expression");
                if (StringUtils.hasText(expression)) {
                    validateJsonPathExpressions.put(expression, jsonPathElement.getAttribute("value"));
                }
            }
        }
    }
1188436
function conversion () {
  var tables = document.querySelectorAll('table')
  var tablesOutput = []
  var i

  if (tables.length === 0) {
    return tablesOutput
  }

  for (i = 0; i < tables.length; i++) {
    var table = tables[i]
    var tableOut = { rows: [] }
    var nameAttr = table.getAttribute('name')
    var dataSheetName = table.dataset.sheetName
    var dataIgnoreName = table.dataset.ignoreSheetName

    if (dataIgnoreName == null) {
      if (dataSheetName != null) {
        tableOut.name = dataSheetName
      } else if (nameAttr != null) {
        tableOut.name = nameAttr
      }
    }

    for (var r = 0, n = table.rows.length; r < n; r++) {
      var row = []
      tableOut.rows.push(row)

      for (var c = 0, m = table.rows[r].cells.length; c < m; c++) {
        var cell = table.rows[r].cells[c]
        var cs = document.defaultView.getComputedStyle(cell, null)
        var type = cell.dataset.cellType != null && cell.dataset.cellType !== '' ? cell.dataset.cellType.toLowerCase() : undefined
        var formatStr = cell.dataset.cellFormatStr != null ? cell.dataset.cellFormatStr : undefined
        var formatEnum = cell.dataset.cellFormatEnum != null && !isNaN(parseInt(cell.dataset.cellFormatEnum, 10)) ? parseInt(cell.dataset.cellFormatEnum, 10) : undefined

        row.push({
          type: type,
          // returns the html inside the td element with special html characters like "&" escaped to &amp;
          value: cell.innerHTML,
          // returns just the real text inside the td element with special html characters like "&" left as it is
          valueText: cell.innerText,
          formatStr: formatStr,
          formatEnum: formatEnum,
          backgroundColor: cs.getPropertyValue('background-color').match(/\d+/g),
          foregroundColor: cs.getPropertyValue('color').match(/\d+/g),
          fontFamily: cs.getPropertyValue('font-family').replace(/["']/g, ''),
          fontSize: cs.getPropertyValue('font-size'),
          fontStyle: cs.getPropertyValue('font-style'),
          fontWeight: cs.getPropertyValue('font-weight'),
          textDecoration: {
            line: cs.getPropertyValue('text-decoration').split(' ')[0]
          },
          verticalAlign: cs.getPropertyValue('vertical-align'),
          horizontalAlign: cs.getPropertyValue('text-align'),
          wrapText: cs.getPropertyValue('overflow'),
          width: cell.clientWidth,
          height: cell.clientHeight,
          rowspan: cell.rowSpan,
          colspan: cell.colSpan,
          border: {
            top: cs.getPropertyValue('border-top-style'),
            topColor: cs.getPropertyValue('border-top-color').match(/\d+/g),
            topStyle: cs.getPropertyValue('border-top-style'),
            topWidth: cs.getPropertyValue('border-top-width'),
            right: cs.getPropertyValue('border-right-style'),
            rightColor: cs.getPropertyValue('border-right-color').match(/\d+/g),
            rightStyle: cs.getPropertyValue('border-right-style'),
            rightWidth: cs.getPropertyValue('border-right-width'),
            bottom: cs.getPropertyValue('border-bottom-style'),
            bottomColor: cs.getPropertyValue('border-bottom-color').match(/\d+/g),
            bottomStyle: cs.getPropertyValue('border-bottom-style'),
            bottomWidth: cs.getPropertyValue('border-bottom-width'),
            left: cs.getPropertyValue('border-left-style'),
            leftColor: cs.getPropertyValue('border-left-color').match(/\d+/g),
            leftStyle: cs.getPropertyValue('border-left-style'),
            leftWidth: cs.getPropertyValue('border-left-width')
          }
        })
      }
    }

    tablesOutput.push(tableOut)
  }

  if (tablesOutput.length === 1) {
    return tablesOutput[0]
  }

  return tablesOutput
}
1203833
private JsonElement parseJsonArrayType(JsonSchema schema, JsonElement value)
      throws DataConversionException {
    Type arrayType = schema.getTypeOfArrayItems();
    JsonArray tempArray = new JsonArray();
    if (Type.isPrimitive(arrayType)) {
      return value;
    }
    JsonSchema nestedSchema = schema.getItemsWithinDataType();
    for (JsonElement v : value.getAsJsonArray()) {
      tempArray.add(parse(v, nestedSchema));
    }
    return tempArray;
  }
227291
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;
        }
    }
362982
public JSONArray toJSON(Collection<SatConstraint> e) throws JSONConverterException {
        JSONArray arr = new JSONArray();
        for (SatConstraint cstr : e) {
            arr.add(toJSON(cstr));
        }
        return arr;
    }
57763
function toJSON() {
    var s = this;
    var values = Object.assign({}, s.schema);
    Object.keys(values).forEach(function (key) {
      var isFunc = iftype.isFunction(values[key]);

      if (isFunc) {
        delete values[key];
      }
    });
    return values;
  }
785949
function convertElement (el, self) {
  if (el instanceof Schema) {
    return el.toObject(self);
  }

  if (isObject(el)) {
    return convertObject(el, self);
  }

  if (Array.isArray(el)) {
    return el.map(function (item) {
      return convertElement(item, self);
    })
  }

  return el;
}
1226983
public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException {
    try {
      JsonReader jsonReader = new JsonReader(reader);
      JsonElement element = parseReader(jsonReader);
      if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
        throw new JsonSyntaxException("Did not consume the entire document.");
      }
      return element;
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);
    } catch (IOException e) {
      throw new JsonIOException(e);
    } catch (NumberFormatException e) {
      throw new JsonSyntaxException(e);
    }
  }