Format output

@param {Object} Object to be formatted according to -p flag
@returns {JSON string}
333474
function formatOutput(obj) {
	if (argv.m) {
		return JSON.stringify(obj);
	}
	return JSON.stringify(obj, null, 2);
}
15720
def pretty_json(obj):
    
    if isinstance(obj, string_types):
        try:
            obj = json.loads(obj)
        except ValueError:
            raise ClientException("`obj` is not a json string")
    json_str = json.dumps(obj, sort_keys=True, indent=2)
    print(highlight(json_str, JsonLexer(), TerminalFormatter()))
276519
public static final String serializeToString(final Object object) {
    if (object == null)
      throw new IllegalArgumentException("Object was null");
    try {
      return jsonMapper.writeValueAsString(object);
    } catch (JsonProcessingException e) {
      throw new JSONException(e);
    }
  }
133276
protected static String prettyPrint(Object obj){
		StringBuilder sb = new StringBuilder();
		if (obj == null){
			sb.append("NULL");
		} else 	if (obj instanceof Blob){
			sb.append(formatLogParam((Blob)obj));
		} else if (obj instanceof Clob){
			sb.append(formatLogParam((Clob)obj));
		} else if (obj instanceof Ref){
			sb.append(formatLogParam((Ref)obj));
		} else if (obj instanceof Array){
			sb.append(formatLogParam((Array)obj));
		} else if (obj instanceof String || obj instanceof Date){
			sb.append("'" + obj.toString()+"'");
		} else {
			sb.append(obj.toString());
		}
		return sb.toString();
	}
1096020
public String toJson(Object object) {

		try {
			return mapper.writeValueAsString(object);
		} catch (IOException e) {
			logger.warn("write to json string error:" + object, e);
			return null;
		}
	}
1234859
function formatOutput (results) {
  var date = new Date()
  var commit

  try {
    commit = execSync('git rev-parse HEAD').toString().replace('\n', '')
  } catch (e) {
    commit = 'commit hash not found'
  }

  return {
    meta: {
      title: 'example benchmark',
      version: pkg.version,
      commit: commit,
      date: [
        date.toLocaleDateString(),
        date.toLocaleTimeString(),
        date.toString().match(/\(([A-Za-z\s].*)\)/)[1]
      ].join(' ')
    },
    results: results
  }
}
1135635
function formatObject(val) {
  if (val.options && val.options.format === false) {
    return val;
  }

  var res = { options: val.options };
  res.files = val.files;
  for (var key in val) {
    if (key === 'files' || key === 'options') {
      continue;
    }
    res[key] = val[key];
  }

  var len = res.files.length;
  var idx = -1;

  while (++idx < len) {
    var ele = res.files[idx];
    var obj = {};

    obj.options = {};
    obj.src = ele.src || [];
    obj.dest = ele.dest || '';

    copyNonfiles(obj, ele);
    if (!ele.options) {
      obj.options = res.options;
    }

    res.files[idx] = obj;
  }
  return res;
}
1087813
function parseOutput(output) {
  if (!output) {
    throw new Error('Expected JSON output');
  }

  let info;
  try {
    info = JSON.parse(String(output));
  } catch (err) {
    throw new Error('Failed to parse output as JSON: ' + output);
  }
  if (!Array.isArray(info.symbols)) {
    throw new Error('Expected symbols array: ' + output);
  }
  if (!Array.isArray(info.defines)) {
    throw new Error('Expected defines array: ' + output);
  }

  return info;
}
520927
def pformat(
    object,
    indent=_UNSET_SENTINEL,
    width=_UNSET_SENTINEL,
    depth=_UNSET_SENTINEL,
    *,
    ribbon_width=_UNSET_SENTINEL,
    max_seq_len=_UNSET_SENTINEL,
    compact=_UNSET_SENTINEL,
    sort_dict_keys=_UNSET_SENTINEL
):
    
    sdocs = python_to_sdocs(
        object,
        **_merge_defaults(
            indent=indent,
            width=width,
            depth=depth,
            ribbon_width=ribbon_width,
            max_seq_len=max_seq_len,
            sort_dict_keys=sort_dict_keys,
        )
    )
    stream = StringIO()
    default_render_to_stream(stream, sdocs)
    return stream.getvalue()
289181
def _format_object(obj, format_type=None):
    """"""

    if json_api_settings.FORMAT_KEYS is not None:
        return format_keys(obj, format_type)

    return format_field_names(obj, format_type)
1299491
def outputjson(self, obj):
        
        self.header('Content-Type', 'application/json')
        self.outputdata(json.dumps(obj).encode('ascii'))
1353059
function formatFileOutput(mappings, type) {
  var string = JSON.stringify(mappings, null, 2);
  if (type === '.js') {
    return 'module.exports=' + string;
  } else if (type === '.json') {
    return string;
  }
}
1047251
function format(input, level, options) {
  if (util.isArray(input)) {
    return array(input, level, options);
  } else if (util.isObject(input)) {
    return object(input, level, options);
  } else {
    return stringify(input, options);
  }
}
1371337
private String format(Object o) {
        return shellSession.format(o, Converter.INSPECT).toString();
    }
268621
function format (args) {
  return args.map((v) => {
    const type = Object.prototype.toString.call(v)
    if (type.toLowerCase() === '[object object]') {
      v = JSON.stringify(v)
    }
    else {
      v = String(v)
    }
    return v
  })
}
344516
function mmToJson( inFileName, printToConsole ) {
    var mm = fs.readFileSync( inFileName, encoding='utf8' );
    var json = xm.load(mm);
    if( printToConsole ) {
        console.log( JSON.stringify( json, null, '    ' ) );
    }
    return json;
}
63887
private static String jsonEncode(Object object) throws IOException {
      
      ObjectMapper mapper = new ObjectMapper();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      try {
         mapper.writeValue(outputStream, object);
         return new String(outputStream.toByteArray());
      } catch (JsonGenerationException e) {
         logger.severe("unable encode");
         throw new IOException(e);
      } catch (JsonMappingException e) {
         logger.severe("unable encode");
         throw new IOException(e.getMessage());
      }
      
   }