# extends PrettyJsonSerializable:
555189
public function jsonLDSerialize(string $context = self::DEFAULT_CONTEXT, bool $types = null)
    {
        $set = array_map(function ($m) use ($types) {
            return is_object($m) ? $m->jsonLDSerialize('', $types) : $m;
        }, $this->members);

        if (!$this->closed) {
            $set[] = null;
        }
        return $set;
    }
828578
public boolean isJsonSerializer( JType type ) {
        return null != type.isClass() && type.isClass().isAssignableTo( jsonSerializerType );
    }
657407
def json_serial(obj):
        

        if isinstance(obj, (datetime.datetime, datetime.date)):
            return obj.isoformat()

        raise TypeError('Type {} not serializable.'.format(type(obj)))
951646
function serializeIntoEqualString(obj) {

        var out = '';

        _.forEach(obj, function(val, key) {
            var stringVal;

            try {
                stringVal = JSON.stringify(val, safeCycles());
            } catch (e) {
                if (safeJsonStringify) {
                    stringVal = safeJsonStringify(val);
                } else {
                    stringVal = 'unserializable! you can install ' +
                                '"safe-json"stringify" module for safer ' +
                                'stringification';
                }
            }

            out += key + '=' + stringVal + ', ';
        });
        // remove last comma
        return out.slice(0, -2);
    }
582792
def fromJSON(value):
        """"""
        if isinstance(value, str):
            value = json.loads(value)
        elif isinstance(value, dict): pass
        else:
            raise AttributeError("Invalid input")
        return Extension(typeName=value['typeName'],
                         capabilities=value['capabilities'],
                         enabled=value['enabled'] == "true",
                         maxUploadFileSize=value['maxUploadFileSize'],
                         allowedUploadFileType=value['allowedUploadFileTypes'],
                         properties=value['properties'])
53573
public static <T extends TBase> String serializeJson(T obj) throws TException {
		// Tried having a static final serializer, but it doesn't seem to be thread safe
		return new TSerializer(new TJSONProtocol.Factory()).toString(obj, THRIFT_CHARSET);
	}
944324
function pretty (msg, obj) {
  console.log(`<------ ${msg} ------>\n` + JSON.stringify(obj, null, ' '))
  console.log(`<------- END -------->\n`)
}
722212
def encode_json(self, serializable):
        
        return json.dumps(serializable.serialize(), cls=self.encoder)
208107
def prettify_json(json_string):
    """"""
    try:
        data = json.loads(json_string)
        html = '<pre>' + json.dumps(data, sort_keys=True, indent=4) + '</pre>'
    except:
        html = json_string
    return mark_safe(html)
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;
        }
    }
479283
private static JsonElement getJsonPrimitive(Object value, Class clazz)
    {
        if (value != null)
        {
            if (clazz.isAssignableFrom(Number.class) || value instanceof Number)
            {
                return new JsonPrimitive((Number) value);
            }
            else if (clazz.isAssignableFrom(Boolean.class) || value instanceof Boolean)
            {
                return new JsonPrimitive((Boolean) value);
            }
            else if (clazz.isAssignableFrom(Character.class) || value instanceof Character)
            {
                return new JsonPrimitive((Character) value);
            }
            else if (clazz.isAssignableFrom(byte[].class) || value instanceof byte[])
            {
                return new JsonPrimitive(PropertyAccessorFactory.STRING.fromBytes(String.class, (byte[]) value));
            }
            else
            {
                return new JsonPrimitive(PropertyAccessorHelper.getString(value));
            }
        }
145406
public function asJson(bool $pretty = false): string
    {
        $response = $this->compile();

        $options = 0;
        if ($pretty) {
            $options = \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT;
        }

        $json = json_encode($response, $options);

        if (false === $json) {
            throw JsonEncodeException::fromJsonError(\json_last_error(), $response);
        }

        return $json;
    }
220468
protected final JSON _with(int features,
            TokenStreamFactory jsonF, TreeCodec trees,
            JSONReader reader, JSONWriter writer,
            PrettyPrinter pp)
    {
        if (getClass() != JSON.class) {
            throw new IllegalStateException("Sub-classes MUST override _with(...)");
        }
        return new JSON(jsonF, trees, features, reader, writer, pp);
    }
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();
    }
852376
@SuppressWarnings("UnusedDeclaration")
  public static Bindings fromJson( String json )
  {
    try
    {
      return PARSER.get().parseJson( json );
    }
    catch( ScriptException e )
    {
      throw new RuntimeException( e );
    }
  }
394698
def stringify(self, obj, beautify=False, raise_exception=False):
        """"""

        return self.helper.string.serialization.json.stringify(
            obj=obj,
            beautify=beautify,
            raise_exception=raise_exception)
1030935
public void showJson(String json) {
		try {
			JsonFactory jsonFactory = new JsonFactory();
			ObjectMapper objectMapper = new ObjectMapper();
			StringWriter stringWriter = new StringWriter();

			JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));
			JsonNode jsonNode = objectMapper.readTree(jsonParser);
			JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
			jsonGenerator.useDefaultPrettyPrinter();

			objectMapper.writeTree(jsonGenerator, jsonNode);

			jsonGenerator.flush();
			jsonGenerator.close();
		} catch (Throwable throwable) {
			// hmm, somewhat accidentally crashed?
		}
	}