解析json字符串，返回兼容解析后的字符串，如果解析错误，返回原始data。
解析器做兼容处理，允许json字符串中存在注释、结束逗号
@param {string} data 原始json字符串数据
345498
function parseJson(data) {
  const parseError = [];
  const parseOptions = {
    disallowComments: false,
    allowTrailingComma: true
  };
  // 使用微软的node-jsonc-parser组件做兼容注释、结束逗号数据，
  // 详细见https://github.com/Microsoft/node-jsonc-parser
  const jsonData = jsonc.parse(data, parseError, parseOptions);
  if (parseError.length !== 0) {
    // 解析错误，直接返回原始数据，以便前端获知错误及原始信息
    return data;
  }
  return JSON.stringify(jsonData);
}
919013
def serialize(self, data):
        
        return json.dumps(self._serialize_datetime(data), ensure_ascii=False)
918173
function parseCommand(data) {
  var command,
      str = data.toString('utf8', 0, data.length);

  command = str.split('\n');
  return command[0];
}
621850
function(a, v, r) {
    if (typeof a == 'object') {
      for (v in a)
        this.data(v, a[v])

    } else if (arguments.length < 2) {
      try {
        return JSON.parse(this.attr('data-' + a))
      } catch(e) {
        return this.attr('data-' + a)
      }

    } else {
      this.attr(
        'data-' + a
      , v === null ?
          null :
        r === true || typeof v === 'string' || typeof v === 'number' ?
          v :
          JSON.stringify(v)
      )
    }

    return this
  }
874253
function __serializeString(data) {
	let dataBuffer = UTF8Encode(data);
	let length = dataBuffer.byteLength;
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, dataBuffer];
}
492896
function(_data,_type){
        try{
            _type = _type.toLowerCase();
            if (_data===null) return _type=='null';
            if (_data===undefined) return _type=='undefined';
            return _o.toString.call(_data).toLowerCase()=='[object '+_type+']';
        }catch(e){
            return !1;
        }
    }
227485
public function jsonResponse($data)
    {
        $this->_headers[] = 'Content-Type: application/json';

        if (!headers_sent()) {
            foreach ($this->_headers as $header) {
                header($header, true);
            }
        }
        echo json_encode($data);
    }
728168
def unwrap_json(self, type, json_data):
        ''''''
        # Parse the data
        try:
            data = json.loads(json_data)
        except ValueError:
            # If parsing failed, then raise the string which likely contains an error message instead of data
            raise RedmineError(json_data)
        # Check to see if there is a data wrapper
        # Some replies will have {'issue':{<data>}} instead of just {<data>}
        try:
            data = data[type]
        except KeyError:
            pass
        return data
957352
function jsonDump (data) {
  if (data == null) return 'null' // python gives a fuck about 'undefined'
  switch (typeof data) {
    case 'number':
    case 'boolean':
      return JSON.stringify(data) // hand off primitives to JSON.stringify
    case 'string':
      return unicodeEscape(JSON.stringify(data)) // strings are special because unicode
    case 'object':
      if (Array.isArray(data)) {
        return '[' + data.map(jsonDump).join(', ') + ']'
      }
      return '{' + Object.keys(data).map(key =>
        '"' + key + '": ' + jsonDump(data[key])).join(', ') + '}'
    default:
      throw new Error('Cannot handle unknown type ' + typeof data + '! Report as ZeroNetJS Bug!')
  }
}
545778
static public function encode($data)
	{
	    if (is_string($data)) {
	        $data = str_replace(array("\r\n"), "", $data);
	        if (strpos($data, '{') ===0 || strpos($data, '[') ===0) {
	            $data = json_decode($data, true);
	        }
	    }
	    
		return json_encode($data);
	}
1167777
function parse(data){
			var out = {};
     		if(data.entry){

	    		var entry = data.entry[0];
	    		
	    		// map data into ufData format from api json

	        	if(utils.getNodeVaue('name.givenName', entry) !== ''){
	        		out['given-name'] = utils.getNodeVaue('name.givenName', entry)
	        	}	

	        	if(utils.getNodeVaue('name.familyName', entry) !== ''){
	        		out['family-name'] = utils.getNodeVaue('name.familyName', entry)
	        	}	

	        	if(utils.getNodeVaue('name.formatted', entry) !== ''){
	        		out.name = utils.getNodeVaue('name.formatted', entry)
	        	}	

	        	if(entry.thumbnailUrl){
	        		out.photo = [entry.thumbnailUrl]
	        	}

	        	if(entry.aboutMe){
	        		out.note = [entry.aboutMe]
	        	}

	        	if(entry.urls){
	        		if(!out.url) {out.url = []};
	        		var i = entry.urls.length;
					var x = 0;
					while (x < i) {
					    out.url.push(entry.urls[x].value);
					    x++;
					}
				}

				if(entry.phoneNumbers){
	        		if(!out.tel) {out.tel = []};
	        		var i = entry.phoneNumbers.length;
					var x = 0;
					while (x < i) {
						if(entry.phoneNumbers[x].type === 'mobile'){
							entry.phoneNumbers[x].type = 'cell'
						}
					    out.tel.push(entry.phoneNumbers[x]);
					    x++;
					}
				}

				if(entry.emails){
	        		if(!out.email) {out.email = []};
	        		var i = entry.emails.length;
					var x = 0;
					while (x < i) {
						if(entry.emails[x].primary && entry.emails[x].primary == 'true'){
							entry.emails[x].type = 'pref';
							delete entry.emails[x].primary;
						}
					    out.email.push(entry.emails[x]);
					    x++;
					}
				}
			}
			return {type: ['h-card'], properties: out};
		}
480323
public BaseDataJsonFieldBo setData(JsonNode data) {
        return setData(
                data == null || data instanceof MissingNode || data instanceof NullNode ? null
                        : SerializationUtils.toJson(data));
    }
680410
function(data){
			//console.log(data);
			//丢弃data的第一行
			var res = '', i = 1, len = data.length;
			for(; i < len; i++){
				res += data[i].replace(/^[\t ]+/, '');
			}
			return res;
		}
942044
public static String successfulJson(Object data) {
        ReturnData returnData = new ReturnData();
        returnData.setSuccess(true);
        returnData.setErrorCode(200);
        returnData.setData(data);
        return JSON.toJSONString(returnData);
    }
301612
public function stringify($data)
    {
        return array_map(function ($item) {
            return is_array($item) ? json_encode($item, JSON_OBJECT_AS_ARRAY) : (string) $item;
        }, $data);
    }
699284
private function _toJson($data)
    {
        if ($data) {
            if (is_array($data)) {
                return json_encode($this->_toCleanArray($data));
            }

            return json_encode($data);
        }
    }
764797
def _data_to_json(data):
        
        if type(data) not in [str, unicode]:
            data = json.dumps(data)
        return data