Passing bytearray from scripting to params breaks the format

When passing this pyArray:

textUEsDBBQABgAIAAAAIQB0DaKhFwIAANkLAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

to a pop up, I'm getting this:

<ArrayWrapper>: [80L, 75L, 3L, 4L, 20L, 0L, 6L, 0L, 8L, 0L, 0L, 0L, 33L, 0L, 116L, 13L, -94L, -95L, 23L, 2L, 0L, 0L, -39L, 11L, 0L, 0L, 19L, 0L, 8L, 2L, 91L, 67L, 111L, 110L, 116L, 101L, 110L, 116L, 95L, 8...

I tried to transform it:

	byte_array = bytearray((b & 0xFF) for b in rawData)
	rawData = base64.b64encode(byte_array).decode('ascii')

And it kinda works, but doesnt return the same thing. It makes it a pyUnicode, and when trying to insert it with an sql query it gives an error:

UEsDBBQABgAIAAAAIQB0DaKhFwIAANkLAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA (type_ class org.python.core.PyUnicode

I want to either pass the data without transforming it or be able to get it back to its initial format.

Assigning anything to a Perspective property (session or component) turns anything not directly supported by JSON into a JSONified substitute. Completely breaking anything like byte arrays or other complex jython objects.

My free Integration Toolkit module offers sessionVarMap(), pageVarMap() and viewVarMap() as an alternate storage location for jython objects that won't destroy their original form.

(There are alternatives using system.util.getGlobals(), but there be dragons.)

3 Likes