// obj must be a pointer to a marshalable object
331001
func marshalYaml(obj runtime.Object) ([]byte, error) {
	y, err := kopscodecs.ToVersionedYaml(obj)
	if err != nil {
		return nil, fmt.Errorf("error marshaling yaml: %v", err)
	}
	return y, nil
}
1333076
func (l *LambdaAliasVersionWeightList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := LambdaAliasVersionWeight{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = LambdaAliasVersionWeightList{item}
		return nil
	}
	list := []LambdaAliasVersionWeight{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = LambdaAliasVersionWeightList(list)
		return nil
	}
	return err
}
1338150
func (l *EventsRuleTargetList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := EventsRuleTarget{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = EventsRuleTargetList{item}
		return nil
	}
	list := []EventsRuleTarget{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = EventsRuleTargetList(list)
		return nil
	}
	return err
}
996326
func (l *EC2InstanceEbsList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := EC2InstanceEbs{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = EC2InstanceEbsList{item}
		return nil
	}
	list := []EC2InstanceEbs{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = EC2InstanceEbsList(list)
		return nil
	}
	return err
}
84419
func Marshal(pb Message) ([]byte, error) {
	// Can the object marshal itself?
	if m, ok := pb.(Marshaler); ok {
		return m.Marshal()
	}
	p := NewBuffer(nil)
	err := p.Marshal(pb)
	var state errorState
	if err != nil && !state.shouldContinue(err, nil) {
		return nil, err
	}
	if p.buf == nil && err == nil {
		// Return a non-nil slice on success.
		return []byte{}, nil
	}
	return p.buf, err
}
60384
func (l *BudgetsBudgetSpendList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := BudgetsBudgetSpend{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = BudgetsBudgetSpendList{item}
		return nil
	}
	list := []BudgetsBudgetSpend{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = BudgetsBudgetSpendList(list)
		return nil
	}
	return err
}
955234
func (l *GlueTriggerPredicateList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := GlueTriggerPredicate{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = GlueTriggerPredicateList{item}
		return nil
	}
	list := []GlueTriggerPredicate{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = GlueTriggerPredicateList(list)
		return nil
	}
	return err
}
846468
func (l *ElasticLoadBalancingV2ListenerCertificatePropertyList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := ElasticLoadBalancingV2ListenerCertificateProperty{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = ElasticLoadBalancingV2ListenerCertificatePropertyList{item}
		return nil
	}
	list := []ElasticLoadBalancingV2ListenerCertificateProperty{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = ElasticLoadBalancingV2ListenerCertificatePropertyList(list)
		return nil
	}
	return err
}
179675
func (d *decodeState) object(v reflect.Value) error {
	// Check for unmarshaler.
	u, ut, pv := indirect(v, false)
	if u != nil {
		start := d.readIndex()
		d.skip()
		return u.UnmarshalJSON(d.data[start:d.off])
	}
	if ut != nil {
		d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)})
		d.skip()
		return nil
	}
	v = pv

	// Decoding into nil interface? Switch to non-reflect code.
	if v.Kind() == reflect.Interface && v.NumMethod() == 0 {
		oi, err := d.objectInterface()
		if err != nil {
			return err
		}
		v.Set(reflect.ValueOf(oi))
		return nil
	}

	// Check type of target:
	//   struct or
	//   map[T1]T2 where T1 is string, an integer type,
	//             or an encoding.TextUnmarshaler
	switch v.Kind() {
	case reflect.Map:
		// Map key must either have string kind, have an integer kind,
		// or be an encoding.TextUnmarshaler.
		t := v.Type()
		switch t.Key().Kind() {
		case reflect.String,
			reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
			reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		default:
			if !reflect.PtrTo(t.Key()).Implements(textUnmarshalerType) {
				d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)})
				d.skip()
				return nil
			}
		}
		if v.IsNil() {
			v.Set(reflect.MakeMap(t))
		}
	case reflect.Struct:
		// ok
	default:
		d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)})
		d.skip()
		return nil
	}

	var mapElem reflect.Value
	originalErrorContext := d.errorContext

	for {
		// Read opening " of string key or closing }.
		d.scanWhile(scanSkipSpace)
		if d.opcode == scanEndObject {
			// closing } - can only happen on first iteration.
			break
		}
		if d.opcode != scanBeginLiteral {
			return errPhase
		}

		// Read key.
		start := d.readIndex()
		d.scanWhile(scanContinue)
		item := d.data[start:d.readIndex()]
		key, ok := unquoteBytes(item)
		if !ok {
			return errPhase
		}

		// Figure out field corresponding to key.
		var subv reflect.Value
		destring := false // whether the value is wrapped in a string to be decoded first

		if v.Kind() == reflect.Map {
			elemType := v.Type().Elem()
			if !mapElem.IsValid() {
				mapElem = reflect.New(elemType).Elem()
			} else {
				mapElem.Set(reflect.Zero(elemType))
			}
			subv = mapElem
		} else {
			var f *field
			fields := cachedTypeFields(v.Type())
			for i := range fields {
				ff := &fields[i]
				if bytes.Equal(ff.nameBytes, key) {
					f = ff
					break
				}
				if f == nil && ff.equalFold(ff.nameBytes, key) {
					f = ff
				}
			}
			if f != nil {
				subv = v
				destring = f.quoted
				for _, i := range f.index {
					if subv.Kind() == reflect.Ptr {
						if subv.IsNil() {
							// If a struct embeds a pointer to an unexported type,
							// it is not possible to set a newly allocated value
							// since the field is unexported.
							//
							// See https://golang.org/issue/21357
							if !subv.CanSet() {
								d.saveError(fmt.Errorf("json: cannot set embedded pointer to unexported struct: %v", subv.Type().Elem()))
								// Invalidate subv to ensure d.value(subv) skips over
								// the JSON value without assigning it to subv.
								subv = reflect.Value{}
								destring = false
								break
							}
							subv.Set(reflect.New(subv.Type().Elem()))
						}
						subv = subv.Elem()
					}
					subv = subv.Field(i)
				}
				d.errorContext.Field = f.name
				d.errorContext.Struct = v.Type().Name()
			} else if d.disallowUnknownFields {
				d.saveError(fmt.Errorf("json: unknown field %q", key))
			}
		}

		// Read : before value.
		if d.opcode == scanSkipSpace {
			d.scanWhile(scanSkipSpace)
		}
		if d.opcode != scanObjectKey {
			return errPhase
		}
		d.scanWhile(scanSkipSpace)

		if destring {
			q, err := d.valueQuoted()
			if err != nil {
				return err
			}
			switch qv := q.(type) {
			case nil:
				if err := d.literalStore(nullLiteral, subv, false); err != nil {
					return err
				}
			case string:
				if err := d.literalStore([]byte(qv), subv, true); err != nil {
					return err
				}
			default:
				d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v", subv.Type()))
			}
		} else {
			if err := d.value(subv); err != nil {
				return err
			}
		}

		// Write value back to map;
		// if using struct, subv points into struct already.
		if v.Kind() == reflect.Map {
			kt := v.Type().Key()
			var kv reflect.Value
			switch {
			case kt.Kind() == reflect.String:
				kv = reflect.ValueOf(key).Convert(kt)
			case reflect.PtrTo(kt).Implements(textUnmarshalerType):
				kv = reflect.New(v.Type().Key())
				if err := d.literalStore(item, kv, true); err != nil {
					return err
				}
				kv = kv.Elem()
			default:
				switch kt.Kind() {
				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
					s := string(key)
					n, err := strconv.ParseInt(s, 10, 64)
					if err != nil || reflect.Zero(kt).OverflowInt(n) {
						d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
						return nil
					}
					kv = reflect.ValueOf(n).Convert(kt)
				case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
					s := string(key)
					n, err := strconv.ParseUint(s, 10, 64)
					if err != nil || reflect.Zero(kt).OverflowUint(n) {
						d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)})
						return nil
					}
					kv = reflect.ValueOf(n).Convert(kt)
				default:
					panic("json: Unexpected key type") // should never occur
				}
			}
			v.SetMapIndex(kv, subv)
		}

		// Next token must be , or }.
		if d.opcode == scanSkipSpace {
			d.scanWhile(scanSkipSpace)
		}
		if d.opcode == scanEndObject {
			break
		}
		if d.opcode != scanObjectValue {
			return errPhase
		}

		d.errorContext = originalErrorContext
	}
	return nil
}
728976
func Marshal(v interface{}) ([]byte, error) {
	rv := reflect.ValueOf(v)
	for rv.Kind() == reflect.Ptr {
		rv = rv.Elem()
	}
	pv := reflect.New(rv.Type())
	pv.Elem().Set(rv)

	if err := applyDefault(pv, true); err != nil {
		return nil, err
	}
	return toml.Marshal(pv.Interface())
}
176128
func (l *DynamoDBTableKeySchemaList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := DynamoDBTableKeySchema{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = DynamoDBTableKeySchemaList{item}
		return nil
	}
	list := []DynamoDBTableKeySchema{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = DynamoDBTableKeySchemaList(list)
		return nil
	}
	return err
}
924943
func (l *GlueTableSkewedInfoList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := GlueTableSkewedInfo{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = GlueTableSkewedInfoList{item}
		return nil
	}
	list := []GlueTableSkewedInfo{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = GlueTableSkewedInfoList(list)
		return nil
	}
	return err
}
1039260
func (configMgr *ConfigurationManager) Unmarshal(obj interface{}) error {
	rv := reflect.ValueOf(obj)
	// only pointers are accepted
	if rv.Kind() != reflect.Ptr || rv.IsNil() {
		err := errors.New("invalid object supplied")
		openlogging.GetLogger().Error("invalid object supplied: " + err.Error())
		return err
	}

	return configMgr.unmarshal(rv, doNotConsiderTag)
}
387765
func (m *memory) Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions, objs chan<- *triple.Object) error {
	if objs == nil {
		return fmt.Errorf("cannot provide an empty channel")
	}

	sUUID := UUIDToByteString(s.UUID())
	pUUID := UUIDToByteString(p.PartialUUID())
	spIdx := sUUID + pUUID
	m.rwmu.RLock()
	defer m.rwmu.RUnlock()
	defer close(objs)

	if lo.LatestAnchor {
		lastTA := make(map[string]*time.Time)
		trps := make(map[string]*triple.Triple)
		for _, t := range m.idxSP[spIdx] {
			p := t.Predicate()
			ppUUID := p.PartialUUID().String()
			if p.Type() == predicate.Temporal {
				ta, err := p.TimeAnchor()
				if err != nil {
					return err
				}
				if lta := lastTA[ppUUID]; lta == nil || ta.Sub(*lta) > 0 {
					trps[ppUUID] = t
					lastTA[ppUUID] = ta
				}
			}
		}
		for _, trp := range trps {
			if trp != nil {
				objs <- trp.Object()
			}
		}
		return nil
	}
	ckr := newChecker(lo, p)
	for _, t := range m.idxSP[spIdx] {
		if ckr.CheckAndUpdate(t.Predicate()) {
			objs <- t.Object()
		}
	}
	return nil
}
485324
func (s Serializers) Serialize(key string, obj interface{}, options ...map[string]interface{}) ([]byte, error) {
	if key == "" {
		return nil, errKeyMissing
	}
	if s == nil {
		return nil, errSerializersEmpty
	}

	serializers := s[key]
	if serializers == nil {
		return nil, errSerializerNotFound.Format(key)
	}
	var finalResult []byte

	for i, n := 0, len(serializers); i < n; i++ {
		result, err := serializers[i].Serialize(obj, options...)
		if err != nil {
			return nil, err
		}
		finalResult = append(finalResult, result...)
	}
	return finalResult, nil
}
950924
func (l *BudgetsBudgetNotificationList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := BudgetsBudgetNotification{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = BudgetsBudgetNotificationList{item}
		return nil
	}
	list := []BudgetsBudgetNotification{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = BudgetsBudgetNotificationList(list)
		return nil
	}
	return err
}
111478
func (l *WAFRegionalRulePredicateList) UnmarshalJSON(buf []byte) error {
	// Cloudformation allows a single object when a list of objects is expected
	item := WAFRegionalRulePredicate{}
	if err := json.Unmarshal(buf, &item); err == nil {
		*l = WAFRegionalRulePredicateList{item}
		return nil
	}
	list := []WAFRegionalRulePredicate{}
	err := json.Unmarshal(buf, &list)
	if err == nil {
		*l = WAFRegionalRulePredicateList(list)
		return nil
	}
	return err
}