code: func (e *Entity) MarshalJSON() ([]byte, error) {
  	// TODO - this implementation does a lot of in-memory copying for simplicity, can probably be optimized.
  	ret := make(map[Property]interface{})
  	if e.Subject != "" {
  		ret["@id"] = e.Subject
  	}
  	for k, v := range e.Objects {
  		if val, exists := ret[k]; exists {
  			return nil, errors.Errorf("invalid entity for json: '%v' already exists at '%v', can't add '%v'", val, k, v)
  		}
  		ret[k] = v
  	}
  	return json.Marshal(ret)
  }
docs: // MarshalJSON is a custom JSON marshaler for Entity objects to ensure that they
  // serialize to valid JSON-LD (https://json-ld.org/ spec/latest/json-ld/). This
  // allows for easy (if not particularly performant) interoperation with other
  // variants of RDF linked data.