diff --git a/Stack/Opc.Ua.Core/Types/Encoders/JsonDecoder.cs b/Stack/Opc.Ua.Core/Types/Encoders/JsonDecoder.cs
index 17bad5a3d2..014b5ee1af 100644
--- a/Stack/Opc.Ua.Core/Types/Encoders/JsonDecoder.cs
+++ b/Stack/Opc.Ua.Core/Types/Encoders/JsonDecoder.cs
@@ -1450,8 +1450,9 @@ namespace Opc.Ua
using (JsonTextWriter writer = new JsonTextWriter(stream))
{
EncodeAsJson(writer, token);
- return new ExtensionObject(typeId, ostrm.ToArray());
}
+ // Close the writer before retrieving the data
+ return new ExtensionObject(typeId, ostrm.ToArray());
}
finally
{
@@ -1463,7 +1464,7 @@ namespace Opc.Ua
/// Reads an encodeable object from the stream.
///
/// The encodeable object field name
- /// The system type of the encopdeable object to be read
+ /// The system type of the encodeable object to be read
/// The TypeId for the instance that will be read.
/// An object that was read from the stream.
public IEncodeable ReadEncodeable(string fieldName, System.Type systemType, ExpandedNodeId encodeableTypeId = null)