From 5fc7c0084395a3984724a6879392ae8182a5ac78 Mon Sep 17 00:00:00 2001 From: Randy Armstrong Date: Sun, 3 Nov 2024 09:37:15 -0800 Subject: [PATCH] Fix JsonEncoder --- Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs b/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs index 2ba8c585b..dde80c60c 100644 --- a/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs +++ b/Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs @@ -1656,26 +1656,28 @@ public void WriteExtensionObject(string fieldName, ExtensionObject value) if (EncodingToUse == JsonEncodingType.Compact) { - WriteNodeId("UaTypeId", localTypeId); - if (encodeable != null) { + WriteNodeId("UaTypeId", localTypeId); encodeable.Encode(this); } else { if (value.Body is JObject json) { + WriteNodeId("UaTypeId", localTypeId); string text = json.ToString(Newtonsoft.Json.Formatting.None); m_writer.Write(text.Substring(1, text.Length - 2)); } else if (value.Encoding == ExtensionObjectEncoding.Binary) { + WriteNodeId("UaTypeId", localTypeId); WriteByte("UaEncoding", (byte)ExtensionObjectEncoding.Binary); WriteByteString("UaBody", value.Body as byte[]); } else if (value.Encoding == ExtensionObjectEncoding.Xml) { + WriteNodeId("UaTypeId", localTypeId); WriteByte("UaEncoding",(byte)ExtensionObjectEncoding.Xml); WriteXmlElement("UaBody", value.Body as XmlElement); }