Skip to content

Commit 29bb123

Browse files
committed
Refactor jsonSet method to improve input handling and streamline type management
1 parent 0a4f6a2 commit 29bb123

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/iop/cls/IOP/Message.cls

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* Copyright (c) 2021 by InterSystems Corporation.
2-
Cambridge, Massachusetts, U.S.A. All rights reserved.
3-
Confidential property of InterSystems Corporation. */
4-
51
Class IOP.Message Extends (Ens.MessageBody, %CSP.Page, %XML.Adaptor)
62
{
73

@@ -79,11 +75,16 @@ Method jsonSet(pInput) As %Status
7975
, "Stream":..jsonStream
8076
, :$$$NULLOREF)
8177
Quit:tOldStream=pInput $$$OK
82-
Do:..type'="" Clear() Set i%type=""
78+
79+
If ..type'="" {
80+
Set:(..type="String") i%jsonString=""
81+
Set:(..type="Stream") i%jsonStream=$$$NULLOREF
82+
Set i%type = ""
83+
}
8384

8485
If $ISOBJECT(pInput) {
8586
if pInput.%Extends("%Stream.GlobalCharacter") {
86-
Set ..jsonStream=pInput, i%type="Stream"
87+
Set r%jsonStream=pInput, i%type="Stream"
8788
}
8889
else {
8990
Throw ##class(%Exception.General).%New("Invalid input type, must be a %Stream.GlobalCharacter or a %String")
@@ -97,15 +98,12 @@ Method jsonSet(pInput) As %Status
9798
Set sc = stream.Write($EXTRACT(pInput,i,(i+..#BUFFER)))
9899
Quit:$$$ISERR(sc)
99100
}
100-
Set ..jsonStream=stream, i%type="Stream"
101+
Set r%jsonStream=stream, i%type="Stream"
102+
}
103+
else {
104+
Set i%jsonString=pInput, i%type="String"
101105
}
102-
Set i%jsonString=pInput, i%type="String"
103106
}
104-
Quit $$$OK
105-
Clear()
106-
If ..type="String" { Set r%jsonString="" }
107-
ElseIf ..type="Stream" { Set r%jsonStream=$$$NULLOREF }
108-
Quit
109107
}
110108

111109
Method GetObjectJson(ByRef atEnd)

0 commit comments

Comments
 (0)