Question
Michael Davidovich · Jun 6

Passing JSON Object to Server (CSP)

Hi there,

I'm passing a JSON object to the server as such:

{"key":"value","key":"value","key":"value"}

From the client:

- Build object

object=JSON.stringify(object)

-pass to server side method as %String

On the server:

s object={}.FromJSON(object)

Instead of getting something like

object=<OBJECT REFERENCE>[2@%Library.DynamicObject]

I get

object="991@%Library.DynamicObject"

I can't access that object using %Get as if says invalid OREF.

I've set the object passed a string to a global and debugged a bit on command line and was successfully able to convert to a dynamic object and use the %Get method to get the value for my key.  I'm doing the exact same thing in the server side code but it doesn't work there.  Typically, I can do it on the command line, I can do it in the code.  I'm not sure what's different between stepping through on the CLI versus running it with they hyperevent.  I must be missing something?  Can someone offer some advice here?

Product version: IRIS 2020.1
$ZV: IRIS for Windows (x86-64) 2020.1.1 (Build 408U) Sun Mar 21 2021 22:04:09 EDT
0
0 93
Discussion (5)1
Log in or sign up to continue
object="991@%Library.DynamicObject"

Somewhere the object was written into a global and read from it.

@Eduard Lebedyuk Thank you.  This IS true since I'm debugging a method defined on CSP page, I'm writing things to a global to check them on the terminal.  So that explains that.

How do you know that means that?

How embarrassing for me.

Pro tip: check the names of your keys when you access them :)

Thanks all!

For some more context, I stopped trying to see what was going on by setting globals to debug.  I set the %response.TraceDump=1 so I can see the %session variable which is were I'm storing the value to the key of the object:

%session.Data("key")=array.%Get("key")

This is still no working as expected.  I even stepped through the code in the command line by calling the zLabel in the INT routine generated from the CSP and it worked as expected there.