Skip to content

Commit

Permalink
Fix JsonEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
randy-armstrong committed Nov 3, 2024
1 parent 73682ed commit 5fc7c00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5fc7c00

Please sign in to comment.