code: func NewPathElement(s string) (fieldpath.PathElement, error) {
  	split := strings.SplitN(s, Separator, 2)
  	if len(split) < 2 {
  		return fieldpath.PathElement{}, fmt.Errorf("missing colon: %v", s)
  	}
  	switch split[0] {
  	case Field:
  		return fieldpath.PathElement{
  			FieldName: &split[1],
  		}, nil
  	case Value:
  		val, err := value.FromJSON([]byte(split[1]))
  		if err != nil {
  			return fieldpath.PathElement{}, err
  		}
  		return fieldpath.PathElement{
  			Value: &val,
  		}, nil
  	case Index:
  		i, err := strconv.Atoi(split[1])
  		if err != nil {
  			return fieldpath.PathElement{}, err
  		}
  		return fieldpath.PathElement{
  			Index: &i,
  		}, nil
  	case Key:
  		kv := map[string]json.RawMessage{}
  		err := json.Unmarshal([]byte(split[1]), &kv)
  		if err != nil {
  			return fieldpath.PathElement{}, err
  		}
  		fields := []value.Field{}
  		for k, v := range kv {
  			b, err := json.Marshal(v)
  			if err != nil {
  				return fieldpath.PathElement{}, err
  			}
  			val, err := value.FromJSON(b)
  			if err != nil {
  				return fieldpath.PathElement{}, err
  			}
  
  			fields = append(fields, value.Field{
  				Name:  k,
  				Value: val,
  			})
  		}
  		return fieldpath.PathElement{
  			Key: fields,
  		}, nil
  	default:
  		// Ignore unknown key types
  		return fieldpath.PathElement{}, nil
  	}
  }
docs: // NewPathElement parses a serialized path element