TODO: Make it so that jsonSerialize doesn't alter the object (currently it adds a self link to the object if none exists)
552927
public function jsonSerialize() {
        $data = [];
        if ($this->errors) $data['errors'] = $this->errors;
        else {
            $data['data'] = $this->data;
            if ((!$this->links || !$this->getLink('self')) && $this->data) {
                if ($this->data instanceof ResourceInterface) {
                    $this->addLink($this->getFactory()->newLink([ 'name' => 'self', 'href' => $this->baseUrl.$this->data->getSelfLinkPath() ]));
                } elseif ($this->data instanceof ResourceCollectionInterface && count($this->data)) {
                    $this->addLink($this->getFactory()->newLink([ 'name' => 'self', 'href' => $this->baseUrl.$this->data[0]->getCollectionLinkPath() ]));
                }
            }

            if (count($this->included)) $data["included"] = $this->included;
        }

        if ($this->links) $data['links'] = $this->links;
        if ($this->meta) $data['meta'] = $this->meta;

        $data['jsonapi'] = $this->jsonapi;

        return $data;
    }
408833
public static JsonNode toJson(Object obj, ClassLoader classLoader) {
        return SerializationUtils.toJson(obj, classLoader);
    }
440444
void buildEntityJson(ObjectNode parent) {
    for (Element child : this.children) {
      ObjectNode node = child.asEntityJson(parent);

      if (node != null) {
        child.buildEntityJson(node);
      } else {
        child.buildEntityJson(parent);
      }
    }
  }
283756
function JSONMinifier() {
  const self = this;
  self.process = ({ output }) => JSON.stringify(JSON.parse(output));
}
769946
public static JsonValue serializeAsJson(Object o) throws IOException {
        try {
            return findFieldsToSerialize(o).mainObject;
        } catch (IllegalStateException ise) {
            // the reflective attempt to build the object failed.
            throw new IOException("Unable to build JSON for Object", ise);
        } catch (JsonException e) {
            throw new IOException("Unable to build JSON for Object", e);
        }
    }
1111529
public JSONObject jsonify() {
    JSONObject ret = new JSONObject();
    ret.put("title", getTitle());
    ret.put("category", getCategory());
    ret.put("subcategory", getSubCategory());
    ret.put("description", getDescription());
    if (null != this._extraAttributes && !this._extraAttributes.isEmpty()) {
      ret.putAll(this._extraAttributes);
    }
    return ret;
  }
1210824
@Override
    public JsonNode getJsonNode(PortletPreferences prefs, String key) throws IOException {
        final String prefValue = StringUtils.trimToNull(prefs.getValue(key, null));
        if (prefValue == null) {
            // Default to an empty object
            return mapper.createObjectNode();
        }
        return mapper.readTree(prefValue);
    }
227042
public void put(String key, Object object, boolean serialize){
        if(serialize)
            put(key,gson.toJson(object));
        else
            put(key,object);
    }
721175
@Override
  public JsonElement serialize(CMAField field, Type type, JsonSerializationContext context) {
    JsonObject json = new JsonObject();

    add(json, ATTR_ID, field.getId());
    add(json, ATTR_NAME, field.getName());
    add(json, ATTR_TYPE, field.getType());
    add(json, ATTR_LINK_TYPE, field.getLinkType());
    add(json, ATTR_REQUIRED, field.isRequired());
    add(json, ATTR_DISABLED, field.isDisabled());
    add(json, ATTR_OMITTED, field.isOmitted());
    add(json, ATTR_LOCALIZED, field.isLocalized());

    List<Map<String, Object>> validations = field.getValidations();
    if (validations != null) {
      json.add(ATTR_VALIDATIONS, context.serialize(validations,
          new TypeToken<List<Map<String, Object>>>() {
          }
          .getType()));
    }

    Map<String, Object> arrayItems = field.getArrayItems();
    if (arrayItems != null) {
      json.add(ATTR_ARRAY_ITEMS, context.serialize(arrayItems, Map.class));
    }

    return json;
  }
867945
@JsonValue
	public Object toJsonValue() {
		if (flags != null)
			return flags;
		if (mode != null)
			return mode;
		return null;
	}
298431
private JSON getJSON() throws JSONMarshallException {
        if (json == null) {
            JSONSettings settings = new JSONSettings(Include.NON_NULL);
            json = JSONFactory.newInstance(settings);
        }
        return json;
    }
487368
private void loadJsonResource(JSONObject json, Properties properties, Object name)
                                throws JSONException {
    Iterator<?> keys = json.keys();
    while (keys.hasNext()) {
      Object obj = keys.next();
      if (!(obj instanceof String)) {
        LOG.warn("Object not instance of string : " + obj + " skipping");
        continue;
      }
      String key = (String) obj;
      // can't have . in thrift fields so we represent . with _
      String keyUnderscoresToDots = key.replace("_", ".");  
      // actual _ are represented as __ in thrift schema
      keyUnderscoresToDots = keyUnderscoresToDots.replace("..", "_");
      if (!json.isNull(key)) {
        Object value = json.get(key);
        String stringVal = "";
        if (value instanceof String) {
          stringVal = (String)value;
        } else if (value instanceof Integer) {
            stringVal = new Integer((Integer)value).toString();
        } else if (value instanceof Long) {
            stringVal = new Long((Long)value).toString();
        } else if (value instanceof Double) {
            stringVal = new Double((Double)value).toString();
        } else if (value instanceof Boolean) {
            stringVal = new Boolean((Boolean)value).toString();
        } else if (value instanceof JSONObject) {
            loadJsonResource((JSONObject)value, properties, name);
            continue;
        } else {
            LOG.warn("unsupported value in json object: " + value);
        }
        if (!finalParameters.contains(keyUnderscoresToDots)) {
          properties.setProperty(keyUnderscoresToDots, stringVal);
          updatingResource.put(keyUnderscoresToDots, name.toString());
    	} else {
    	    LOG.warn(name+":a attempt to override final parameter: "+
                     keyUnderscoresToDots+";  Ignoring.");
    	}
      } 
    }
  }
1067380
function deserialize(serialized){
    serialized.nodes.forEach(function (node){ addNode(node.id); });
    serialized.links.forEach(function (link){ addEdge(link.source, link.target, link.weight); });
    return graph;
  }
313437
protected final JSON defaultCreateJSON( Map model ) {
      if( skipBindingResult && jsonConfig.getJsonPropertyFilter() == null ){
         this.jsonConfig.setJsonPropertyFilter( new BindingResultPropertyFilter() );
      }
      return JSONSerializer.toJSON( model, jsonConfig );
   }
58411
JSONObject toJson() {
        JSONObject ret = new JSONObject();
        ret.put("type",type.name());
        if (targetConfig != null) {
            ret.put("target",targetConfig.toJson());
        }
        return ret;
    }
524867
public void addJSONObject(JSONObject obj)
    {
        if (logger.isLoggable(Level.FINER)) logger.entering(className, "addJSONObject(JSONObject)");

        Vector vect = (Vector) this.jsonObjects.get(obj.objectName);
        if (vect != null)
        {
            vect.add(obj);
        }
        else
        {
            vect = new Vector();
            vect.add(obj);
            this.jsonObjects.put(obj.objectName, vect);
        }

        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "addJSONObject(JSONObject)");
    }
19630
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
            final boolean includeNullValuedFields, final int depth, final int indentWidth,
            final StringBuilder buf) {
        final boolean prettyPrint = indentWidth > 0;
        final int n = items.size();
        if (n == 0) {
            buf.append("[]");
        } else {
            buf.append('[');
            if (prettyPrint) {
                buf.append('\n');
            }
            for (int i = 0; i < n; i++) {
                final Object item = items.get(i);
                if (prettyPrint) {
                    JSONUtils.indent(depth + 1, indentWidth, buf);
                }
                JSONSerializer.jsonValToJSONString(item, jsonReferenceToId, includeNullValuedFields, depth + 1,
                        indentWidth, buf);
                if (i < n - 1) {
                    buf.append(',');
                }
                if (prettyPrint) {
                    buf.append('\n');
                }
            }
            if (prettyPrint) {
                JSONUtils.indent(depth, indentWidth, buf);
            }
            buf.append(']');
        }
    }