Encodes this workitem as JSON. If pretty is set to true, will output
 prettified JSON.
555866
def as_json(pretty=false)

      pretty ? Rufus::Json.pretty_encode(@h) : Rufus::Json.encode(@h)
    end
1234919
def pretty_json(data):
    
    data = json.loads(data.decode('utf-8'))
    return json.dumps(data, indent=4, sort_keys=True)
870360
public String toJson(boolean pretty, String ... attrs) {
        hydrate();
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        if (pretty) sb.append('\n');

        for (int i = 0; i < delegate.size(); i++) {
            if (i > 0) {
                sb.append(',');
                if (pretty) { sb.append('\n'); }
            }
            delegate.get(i).toJsonP(sb, pretty, (pretty ? "  " : ""), attrs);
        }
        if (pretty) { sb.append('\n'); }
        sb.append(']');
        return sb.toString();
    }
881488
def _json_pretty_print(self, content):
        
        temp = json.loads(content)
        return json.dumps(
            temp,
            sort_keys=True,
            indent=4,
            separators=(
                ',',
                ': '))
175667
def json(value, pretty=True):
    
    if not _Duration:
        _late_import()
    return _json_encoder(value, pretty=pretty)
677383
def to_json(data, pretty):
    
    if pretty:
        return json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
    return json.dumps(data)
505043
def export_as_json(self):
        
        return {
            "items": {
                str(jid): item.export_as_json()
                for jid, item in self.items.items()
            },
            "ver": self.version
        }
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
338374
def to_json(obj, pretty=False):
  
  sort_keys = False
  indent = None
  separators = (",", ":")

  if isinstance(pretty, tuple):
    sort_keys, indent, separators = pretty
  elif pretty is True:
    sort_keys = True
    indent = 2
    separators = (", ", ": ")

  return json.dumps(obj, sort_keys=sort_keys, indent=indent, separators=separators,
                    default=json_default)
481727
public String exportToJson(boolean pretty) {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, List<Map<String, Object>>> services = new HashMap<String, List<Map<String, Object>>>();

        for (EndpointHealth h : endpoints) {
            String type = serviceTypeFromEnum(h.type());
            if (!services.containsKey(type)) {
                services.put(type, new ArrayList<Map<String, Object>>());
            }
            List<Map<String, Object>> eps = services.get(type);
            eps.add(h.toMap());
        }

        result.put("version", version);
        result.put("services", services);
        result.put("sdk", sdk);
        result.put("id", id);

        try {
            if (pretty) {
                return DefaultObjectMapper.prettyWriter().writeValueAsString(result);
            } else {
                return DefaultObjectMapper.writeValueAsString(result);
            }
        } catch (JsonProcessingException e) {
            throw new IllegalStateException("Could not encode as JSON string.", e);
        }
    }
114382
public function toJSON($JSON_PRETTY_PRINT = false)
    {
        $object = $this->toObject();

        /*foreach ($object as $key => &$attribute) {
            //Check if any of attributes is an instance of BaseValidator
            if (is_object($attribute) && is_a($attribute, BaseValidator::class)) {
                $attribute = $attribute->toObject();
            }
        }*/

        return json_encode(
            $object,
            ($JSON_PRETTY_PRINT ? JSON_PRETTY_PRINT : 0)
        );
    }
824140
function prettify(data) {
    let json = JSON.stringify(data);
    json = json.replace(/{/g, "{\n\n\t");
    json = json.replace(/,/g, ",\n\t");
    json = json.replace(/}/g, ",\n\n}");
    return json;
  }
307323
def jsonify(result, format=False):
    '''  '''

    result2 = result.copy()
    if format:
        return json.dumps(result2, sort_keys=True, indent=4)
    else:
        return json.dumps(result2, sort_keys=True)
812431
def write_dicts_to_json(self, data):
        
        with open(self.path, "w") as out:
            json.dump(
                data,  # data
                out,  # file handler
                indent=4, sort_keys=True  # pretty print
            )
489588
def to_json
      new_json = JSON.pretty_generate(@data)
      # nuke empty lines
      new_json = new_json.split("\n").reject(&:empty?).join("\n") + "\n"
      new_json
    end
351553
def jsonify(py_data, default=None, indent=4, sort_keys=True):
    
    return json.dumps(py_data, default=py2json, indent=indent, sort_keys=sort_keys)
1346439
def encode_json_body(data):
    
    # support for StringIO / file - like objects
    if hasattr(data, "read"):
        return data

    response.content_type = "application/json; charset=utf-8"

    return json.dumps(
        data,
        indent=4,
        separators=(',', ': ')
    )