func (x *ApplicationInvalidatedDownlinks) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.Downlinks) > 0 || s.HasField("downlinks") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("downlinks")
		s.WriteArrayStart()
		var wroteElement bool
		for _, element := range x.Downlinks {
			s.WriteMoreIf(&wroteElement)
			element.MarshalProtoJSON(s.WithField("downlinks"))
		}
		s.WriteArrayEnd()
	}
	if x.LastFCntDown != 0 || s.HasField("last_f_cnt_down") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("last_f_cnt_down")
		s.WriteUint32(x.LastFCntDown)
	}
	if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("session_key_id")
		s.WriteBytes(x.SessionKeyId)
	}
	s.WriteObjectEnd()
}
MarshalProtoJSON marshals the ApplicationInvalidatedDownlinks message to JSON.
package ttnpb
import (
	gogo "github.com/TheThingsIndustries/protoc-gen-go-json/gogo"
	jsonplugin "github.com/TheThingsIndustries/protoc-gen-go-json/jsonplugin"
)
func (x PayloadFormatter) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	s.WriteEnumString(int32(x), PayloadFormatter_name)
}
var PayloadFormatter_customvalue = map[string]int32{
	"NONE":         0,
	"REPOSITORY":   1,
	"GRPC_SERVICE": 2,
	"JAVASCRIPT":   3,
	"CAYENNELPP":   4,
}
func (x *PayloadFormatter) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	v := s.ReadEnum(PayloadFormatter_value, PayloadFormatter_customvalue)
	if err := s.Err(); err != nil {
		s.SetErrorf("could not read PayloadFormatter enum: %v", err)
		return
	}
	*x = PayloadFormatter(v)
}
func (x *UplinkMessage) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.RawPayload) > 0 || s.HasField("raw_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("raw_payload")
		s.WriteBytes(x.RawPayload)
	}
	if x.Payload != nil || s.HasField("payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("payload")
		x.Payload.MarshalProtoJSON(s.WithField("payload"))
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("settings")
		x.Settings.MarshalProtoJSON(s.WithField("settings"))
	}
	if len(x.RxMetadata) > 0 || s.HasField("rx_metadata") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("rx_metadata")
		s.WriteArrayStart()
		var wroteElement bool
		for _, element := range x.RxMetadata {
			s.WriteMoreIf(&wroteElement)
			element.MarshalProtoJSON(s.WithField("rx_metadata"))
		}
		s.WriteArrayEnd()
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("received_at")
		s.WriteTime(x.ReceivedAt)
	}
	if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("correlation_ids")
		s.WriteStringArray(x.CorrelationIds)
	}
	if x.DeviceChannelIndex != 0 || s.HasField("device_channel_index") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("device_channel_index")
		s.WriteUint32(x.DeviceChannelIndex)
	}
	if x.ConsumedAirtime != nil || s.HasField("consumed_airtime") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("consumed_airtime")
		if x.ConsumedAirtime == nil {
			s.WriteNil()
		} else {
			s.WriteDuration(*x.ConsumedAirtime)
		}
	}
	s.WriteObjectEnd()
}
func (x *UplinkMessage) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "raw_payload", "rawPayload":
			s.AddField("raw_payload")
			x.RawPayload = s.ReadBytes()
		case "payload":
			if !s.ReadNil() {
				x.Payload = &Message{}
				x.Payload.UnmarshalProtoJSON(s.WithField("payload", true))
			}
		case "settings":
			if !s.ReadNil() {
				x.Settings.UnmarshalProtoJSON(s.WithField("settings", true))
			}
		case "rx_metadata", "rxMetadata":
			s.AddField("rx_metadata")
			s.ReadArray(func() {
				if s.ReadNil() {
					x.RxMetadata = append(x.RxMetadata, nil)
					return
				}
				v := &RxMetadata{}
				v.UnmarshalProtoJSON(s.WithField("rx_metadata", false))
				if s.Err() != nil {
					return
				}
				x.RxMetadata = append(x.RxMetadata, v)
			})
		case "received_at", "receivedAt":
			s.AddField("received_at")
			v := s.ReadTime()
			if s.Err() != nil {
				return
			}
			x.ReceivedAt = *v
		case "correlation_ids", "correlationIds":
			s.AddField("correlation_ids")
			x.CorrelationIds = s.ReadStringArray()
		case "device_channel_index", "deviceChannelIndex":
			s.AddField("device_channel_index")
			x.DeviceChannelIndex = s.ReadUint32()
		case "consumed_airtime", "consumedAirtime":
			s.AddField("consumed_airtime")
			v := s.ReadDuration()
			if s.Err() != nil {
				return
			}
			x.ConsumedAirtime = v
		}
	})
}
func (x *DownlinkMessage) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.RawPayload) > 0 || s.HasField("raw_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("raw_payload")
		s.WriteBytes(x.RawPayload)
	}
	if x.Payload != nil || s.HasField("payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("payload")
		x.Payload.MarshalProtoJSON(s.WithField("payload"))
	}
	if x.EndDeviceIds != nil || s.HasField("end_device_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("end_device_ids")
		gogo.MarshalMessage(s, x.EndDeviceIds)
	}
	if x.Settings != nil {
		switch ov := x.Settings.(type) {
		case *DownlinkMessage_Request:
			s.WriteMoreIf(&wroteField)
			s.WriteObjectField("request")
			ov.Request.MarshalProtoJSON(s.WithField("request"))
		case *DownlinkMessage_Scheduled:
			s.WriteMoreIf(&wroteField)
			s.WriteObjectField("scheduled")
			ov.Scheduled.MarshalProtoJSON(s.WithField("scheduled"))
		}
	}
	if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("correlation_ids")
		s.WriteStringArray(x.CorrelationIds)
	}
	if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("session_key_id")
		s.WriteBytes(x.SessionKeyId)
	}
	s.WriteObjectEnd()
}
func (x *DownlinkMessage) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "raw_payload", "rawPayload":
			s.AddField("raw_payload")
			x.RawPayload = s.ReadBytes()
		case "payload":
			if !s.ReadNil() {
				x.Payload = &Message{}
				x.Payload.UnmarshalProtoJSON(s.WithField("payload", true))
			}
		case "end_device_ids", "endDeviceIds":
			s.AddField("end_device_ids")
			var v EndDeviceIdentifiers
			gogo.UnmarshalMessage(s, &v)
			x.EndDeviceIds = &v
		case "request":
			ov := &DownlinkMessage_Request{}
			if !s.ReadNil() {
				ov.Request = &TxRequest{}
				ov.Request.UnmarshalProtoJSON(s.WithField("request", true))
			}
			x.Settings = ov
		case "scheduled":
			ov := &DownlinkMessage_Scheduled{}
			if !s.ReadNil() {
				ov.Scheduled = &TxSettings{}
				ov.Scheduled.UnmarshalProtoJSON(s.WithField("scheduled", true))
			}
			x.Settings = ov
		case "correlation_ids", "correlationIds":
			s.AddField("correlation_ids")
			x.CorrelationIds = s.ReadStringArray()
		case "session_key_id", "sessionKeyId":
			s.AddField("session_key_id")
			x.SessionKeyId = s.ReadBytes()
		}
	})
}
func (x TxAcknowledgment_Result) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	s.WriteEnumString(int32(x), TxAcknowledgment_Result_name)
}
func (x *TxAcknowledgment_Result) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	v := s.ReadEnum(TxAcknowledgment_Result_value)
	if err := s.Err(); err != nil {
		s.SetErrorf("could not read Result enum: %v", err)
		return
	}
	*x = TxAcknowledgment_Result(v)
}
func (x *TxAcknowledgment) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("correlation_ids")
		s.WriteStringArray(x.CorrelationIds)
	}
	if x.Result != 0 || s.HasField("result") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("result")
		x.Result.MarshalProtoJSON(s)
	}
	if x.DownlinkMessage != nil || s.HasField("downlink_message") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("downlink_message")
		x.DownlinkMessage.MarshalProtoJSON(s.WithField("downlink_message"))
	}
	s.WriteObjectEnd()
}
func (x *TxAcknowledgment) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "correlation_ids", "correlationIds":
			s.AddField("correlation_ids")
			x.CorrelationIds = s.ReadStringArray()
		case "result":
			s.AddField("result")
			x.Result.UnmarshalProtoJSON(s)
		case "downlink_message", "downlinkMessage":
			if !s.ReadNil() {
				x.DownlinkMessage = &DownlinkMessage{}
				x.DownlinkMessage.UnmarshalProtoJSON(s.WithField("downlink_message", true))
			}
		}
	})
}
func (x *GatewayTxAcknowledgment) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if x.GatewayIds != nil || s.HasField("gateway_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("gateway_ids")
		gogo.MarshalMessage(s, x.GatewayIds)
	}
	if x.TxAck != nil || s.HasField("tx_ack") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("tx_ack")
		x.TxAck.MarshalProtoJSON(s.WithField("tx_ack"))
	}
	s.WriteObjectEnd()
}
func (x *GatewayTxAcknowledgment) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "gateway_ids", "gatewayIds":
			s.AddField("gateway_ids")
			var v GatewayIdentifiers
			gogo.UnmarshalMessage(s, &v)
			x.GatewayIds = &v
		case "tx_ack", "txAck":
			if !s.ReadNil() {
				x.TxAck = &TxAcknowledgment{}
				x.TxAck.UnmarshalProtoJSON(s.WithField("tx_ack", true))
			}
		}
	})
}
func (x *GatewayUplinkMessage) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if x.UplinkMessage != nil || s.HasField("message") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("message")
		x.UplinkMessage.MarshalProtoJSON(s.WithField("message"))
	}
	if x.BandId != "" || s.HasField("band_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("band_id")
		s.WriteString(x.BandId)
	}
	s.WriteObjectEnd()
}
func (x *GatewayUplinkMessage) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "message":
			if !s.ReadNil() {
				x.UplinkMessage = &UplinkMessage{}
				x.UplinkMessage.UnmarshalProtoJSON(s.WithField("message", true))
			}
		case "band_id", "bandId":
			s.AddField("band_id")
			x.BandId = s.ReadString()
		}
	})
}
func (x *ApplicationUplink) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("session_key_id")
		s.WriteBytes(x.SessionKeyId)
	}
	if x.FPort != 0 || s.HasField("f_port") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("f_port")
		s.WriteUint32(x.FPort)
	}
	if x.FCnt != 0 || s.HasField("f_cnt") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("f_cnt")
		s.WriteUint32(x.FCnt)
	}
	if len(x.FrmPayload) > 0 || s.HasField("frm_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("frm_payload")
		s.WriteBytes(x.FrmPayload)
	}
	if x.DecodedPayload != nil || s.HasField("decoded_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("decoded_payload")
		if x.DecodedPayload == nil {
			s.WriteNil()
		} else {
			gogo.MarshalStruct(s, x.DecodedPayload)
		}
	}
	if len(x.DecodedPayloadWarnings) > 0 || s.HasField("decoded_payload_warnings") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("decoded_payload_warnings")
		s.WriteStringArray(x.DecodedPayloadWarnings)
	}
	if len(x.RxMetadata) > 0 || s.HasField("rx_metadata") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("rx_metadata")
		s.WriteArrayStart()
		var wroteElement bool
		for _, element := range x.RxMetadata {
			s.WriteMoreIf(&wroteElement)
			element.MarshalProtoJSON(s.WithField("rx_metadata"))
		}
		s.WriteArrayEnd()
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("settings")
		x.Settings.MarshalProtoJSON(s.WithField("settings"))
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("received_at")
		s.WriteTime(x.ReceivedAt)
	}
	if x.AppSKey != nil || s.HasField("app_s_key") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("app_s_key")
		gogo.MarshalMessage(s, x.AppSKey)
	}
	if x.LastAFCntDown != 0 || s.HasField("last_a_f_cnt_down") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("last_a_f_cnt_down")
		s.WriteUint32(x.LastAFCntDown)
	}
	if x.Confirmed || s.HasField("confirmed") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("confirmed")
		s.WriteBool(x.Confirmed)
	}
	if x.ConsumedAirtime != nil || s.HasField("consumed_airtime") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("consumed_airtime")
		if x.ConsumedAirtime == nil {
			s.WriteNil()
		} else {
			s.WriteDuration(*x.ConsumedAirtime)
		}
	}
	if x.Locations != nil || s.HasField("locations") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("locations")
		s.WriteObjectStart()
		var wroteElement bool
		for k, v := range x.Locations {
			s.WriteMoreIf(&wroteElement)
			s.WriteObjectStringField(k)
			v.MarshalProtoJSON(s.WithField("locations"))
		}
		s.WriteObjectEnd()
	}
	if x.VersionIds != nil || s.HasField("version_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("version_ids")
		gogo.MarshalMessage(s, x.VersionIds)
	}
	if x.NetworkIds != nil || s.HasField("network_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("network_ids")
		gogo.MarshalMessage(s, x.NetworkIds)
	}
	s.WriteObjectEnd()
}
func (x *ApplicationUplink) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "session_key_id", "sessionKeyId":
			s.AddField("session_key_id")
			x.SessionKeyId = s.ReadBytes()
		case "f_port", "fPort":
			s.AddField("f_port")
			x.FPort = s.ReadUint32()
		case "f_cnt", "fCnt":
			s.AddField("f_cnt")
			x.FCnt = s.ReadUint32()
		case "frm_payload", "frmPayload":
			s.AddField("frm_payload")
			x.FrmPayload = s.ReadBytes()
		case "decoded_payload", "decodedPayload":
			s.AddField("decoded_payload")
			v := gogo.UnmarshalStruct(s)
			if s.Err() != nil {
				return
			}
			x.DecodedPayload = v
		case "decoded_payload_warnings", "decodedPayloadWarnings":
			s.AddField("decoded_payload_warnings")
			x.DecodedPayloadWarnings = s.ReadStringArray()
		case "rx_metadata", "rxMetadata":
			s.AddField("rx_metadata")
			s.ReadArray(func() {
				if s.ReadNil() {
					x.RxMetadata = append(x.RxMetadata, nil)
					return
				}
				v := &RxMetadata{}
				v.UnmarshalProtoJSON(s.WithField("rx_metadata", false))
				if s.Err() != nil {
					return
				}
				x.RxMetadata = append(x.RxMetadata, v)
			})
		case "settings":
			if !s.ReadNil() {
				x.Settings.UnmarshalProtoJSON(s.WithField("settings", true))
			}
		case "received_at", "receivedAt":
			s.AddField("received_at")
			v := s.ReadTime()
			if s.Err() != nil {
				return
			}
			x.ReceivedAt = *v
		case "app_s_key", "appSKey":
			s.AddField("app_s_key")
			var v KeyEnvelope
			gogo.UnmarshalMessage(s, &v)
			x.AppSKey = &v
		case "last_a_f_cnt_down", "lastAFCntDown":
			s.AddField("last_a_f_cnt_down")
			x.LastAFCntDown = s.ReadUint32()
		case "confirmed":
			s.AddField("confirmed")
			x.Confirmed = s.ReadBool()
		case "consumed_airtime", "consumedAirtime":
			s.AddField("consumed_airtime")
			v := s.ReadDuration()
			if s.Err() != nil {
				return
			}
			x.ConsumedAirtime = v
		case "locations":
			s.AddField("locations")
			x.Locations = make(map[string]*Location)
			s.ReadStringMap(func(key string) {
				var v Location
				v.UnmarshalProtoJSON(s)
				x.Locations[key] = &v
			})
		case "version_ids", "versionIds":
			s.AddField("version_ids")
			var v EndDeviceVersionIdentifiers
			gogo.UnmarshalMessage(s, &v)
			x.VersionIds = &v
		case "network_ids", "networkIds":
			s.AddField("network_ids")
			var v NetworkIdentifiers
			gogo.UnmarshalMessage(s, &v)
			x.NetworkIds = &v
		}
	})
}
func (x *ApplicationLocation) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if x.Service != "" || s.HasField("service") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("service")
		s.WriteString(x.Service)
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("location")
		x.Location.MarshalProtoJSON(s.WithField("location"))
	}
	if x.Attributes != nil || s.HasField("attributes") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("attributes")
		s.WriteObjectStart()
		var wroteElement bool
		for k, v := range x.Attributes {
			s.WriteMoreIf(&wroteElement)
			s.WriteObjectStringField(k)
			s.WriteString(v)
		}
		s.WriteObjectEnd()
	}
	s.WriteObjectEnd()
}
func (x *ApplicationLocation) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "service":
			s.AddField("service")
			x.Service = s.ReadString()
		case "location":
			if !s.ReadNil() {
				x.Location.UnmarshalProtoJSON(s.WithField("location", true))
			}
		case "attributes":
			s.AddField("attributes")
			x.Attributes = make(map[string]string)
			s.ReadStringMap(func(key string) {
				x.Attributes[key] = s.ReadString()
			})
		}
	})
}
func (x *ApplicationJoinAccept) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("session_key_id")
		s.WriteBytes(x.SessionKeyId)
	}
	if x.AppSKey != nil || s.HasField("app_s_key") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("app_s_key")
		gogo.MarshalMessage(s, x.AppSKey)
	}
	if len(x.InvalidatedDownlinks) > 0 || s.HasField("invalidated_downlinks") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("invalidated_downlinks")
		s.WriteArrayStart()
		var wroteElement bool
		for _, element := range x.InvalidatedDownlinks {
			s.WriteMoreIf(&wroteElement)
			element.MarshalProtoJSON(s.WithField("invalidated_downlinks"))
		}
		s.WriteArrayEnd()
	}
	if x.PendingSession || s.HasField("pending_session") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("pending_session")
		s.WriteBool(x.PendingSession)
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("received_at")
		s.WriteTime(x.ReceivedAt)
	}
	s.WriteObjectEnd()
}
func (x *ApplicationJoinAccept) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "session_key_id", "sessionKeyId":
			s.AddField("session_key_id")
			x.SessionKeyId = s.ReadBytes()
		case "app_s_key", "appSKey":
			s.AddField("app_s_key")
			var v KeyEnvelope
			gogo.UnmarshalMessage(s, &v)
			x.AppSKey = &v
		case "invalidated_downlinks", "invalidatedDownlinks":
			s.AddField("invalidated_downlinks")
			s.ReadArray(func() {
				if s.ReadNil() {
					x.InvalidatedDownlinks = append(x.InvalidatedDownlinks, nil)
					return
				}
				v := &ApplicationDownlink{}
				v.UnmarshalProtoJSON(s.WithField("invalidated_downlinks", false))
				if s.Err() != nil {
					return
				}
				x.InvalidatedDownlinks = append(x.InvalidatedDownlinks, v)
			})
		case "pending_session", "pendingSession":
			s.AddField("pending_session")
			x.PendingSession = s.ReadBool()
		case "received_at", "receivedAt":
			s.AddField("received_at")
			v := s.ReadTime()
			if s.Err() != nil {
				return
			}
			x.ReceivedAt = *v
		}
	})
}
func (x *ApplicationDownlink) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.SessionKeyId) > 0 || s.HasField("session_key_id") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("session_key_id")
		s.WriteBytes(x.SessionKeyId)
	}
	if x.FPort != 0 || s.HasField("f_port") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("f_port")
		s.WriteUint32(x.FPort)
	}
	if x.FCnt != 0 || s.HasField("f_cnt") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("f_cnt")
		s.WriteUint32(x.FCnt)
	}
	if len(x.FrmPayload) > 0 || s.HasField("frm_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("frm_payload")
		s.WriteBytes(x.FrmPayload)
	}
	if x.DecodedPayload != nil || s.HasField("decoded_payload") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("decoded_payload")
		if x.DecodedPayload == nil {
			s.WriteNil()
		} else {
			gogo.MarshalStruct(s, x.DecodedPayload)
		}
	}
	if len(x.DecodedPayloadWarnings) > 0 || s.HasField("decoded_payload_warnings") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("decoded_payload_warnings")
		s.WriteStringArray(x.DecodedPayloadWarnings)
	}
	if x.Confirmed || s.HasField("confirmed") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("confirmed")
		s.WriteBool(x.Confirmed)
	}
	if x.ClassBC != nil || s.HasField("class_b_c") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("class_b_c")
		gogo.MarshalMessage(s, x.ClassBC)
	}
	if x.Priority != 0 || s.HasField("priority") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("priority")
		x.Priority.MarshalProtoJSON(s)
	}
	if len(x.CorrelationIds) > 0 || s.HasField("correlation_ids") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("correlation_ids")
		s.WriteStringArray(x.CorrelationIds)
	}
	s.WriteObjectEnd()
}
func (x *ApplicationDownlink) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "session_key_id", "sessionKeyId":
			s.AddField("session_key_id")
			x.SessionKeyId = s.ReadBytes()
		case "f_port", "fPort":
			s.AddField("f_port")
			x.FPort = s.ReadUint32()
		case "f_cnt", "fCnt":
			s.AddField("f_cnt")
			x.FCnt = s.ReadUint32()
		case "frm_payload", "frmPayload":
			s.AddField("frm_payload")
			x.FrmPayload = s.ReadBytes()
		case "decoded_payload", "decodedPayload":
			s.AddField("decoded_payload")
			v := gogo.UnmarshalStruct(s)
			if s.Err() != nil {
				return
			}
			x.DecodedPayload = v
		case "decoded_payload_warnings", "decodedPayloadWarnings":
			s.AddField("decoded_payload_warnings")
			x.DecodedPayloadWarnings = s.ReadStringArray()
		case "confirmed":
			s.AddField("confirmed")
			x.Confirmed = s.ReadBool()
		case "class_b_c", "classBC":
			s.AddField("class_b_c")
			var v ApplicationDownlink_ClassBC
			gogo.UnmarshalMessage(s, &v)
			x.ClassBC = &v
		case "priority":
			s.AddField("priority")
			x.Priority.UnmarshalProtoJSON(s)
		case "correlation_ids", "correlationIds":
			s.AddField("correlation_ids")
			x.CorrelationIds = s.ReadStringArray()
		}
	})
}
func (x *ApplicationDownlinks) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if len(x.Downlinks) > 0 || s.HasField("downlinks") {
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("downlinks")
		s.WriteArrayStart()
		var wroteElement bool
		for _, element := range x.Downlinks {
			s.WriteMoreIf(&wroteElement)
			element.MarshalProtoJSON(s.WithField("downlinks"))
		}
		s.WriteArrayEnd()
	}
	s.WriteObjectEnd()
}
func (x *ApplicationDownlinks) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "downlinks":
			s.AddField("downlinks")
			s.ReadArray(func() {
				if s.ReadNil() {
					x.Downlinks = append(x.Downlinks, nil)
					return
				}
				v := &ApplicationDownlink{}
				v.UnmarshalProtoJSON(s.WithField("downlinks", false))
				if s.Err() != nil {
					return
				}
				x.Downlinks = append(x.Downlinks, v)
			})
		}
	})
}
func (x *ApplicationDownlinkFailed) MarshalProtoJSON(s *jsonplugin.MarshalState) {
	if x == nil {
		s.WriteNil()
		return
	}
	s.WriteObjectStart()
	var wroteField bool
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("downlink")
		x.ApplicationDownlink.MarshalProtoJSON(s.WithField("downlink"))
	}
	if true {  
		s.WriteMoreIf(&wroteField)
		s.WriteObjectField("error")
		gogo.MarshalMessage(s, &x.Error)
	}
	s.WriteObjectEnd()
}
func (x *ApplicationDownlinkFailed) UnmarshalProtoJSON(s *jsonplugin.UnmarshalState) {
	if s.ReadNil() {
		return
	}
	s.ReadObject(func(key string) {
		switch key {
		default:
			s.ReadAny()  
		case "downlink":
			if !s.ReadNil() {
				x.ApplicationDownlink.UnmarshalProtoJSON(s.WithField("downlink", true))
			}
		case "error":
			s.AddField("error")
			var v ErrorDetails
			gogo.UnmarshalMessage(s, &v)
			x.Error = v
		}
	})
}