How to build a variable holding JSON data in a class method?

mcraig.brs

New Member
Progress 10.2b on Red Hat Linux

I have 2 questions that are related about Streams and JSON.

1. How can I take a temp-table and convert it to a JSON string and place that string in a variable that can be passed through a METHOD of a class.
2. How can I take a temp-table and export it to a file using class Method.

I have read through the JSON manual, and I do not see how to do these in an object oreinted way. I keep getting the error that I cannot have a stream in a function or method.

I figure this is something simple I just don't know where to look.

Any help is apreciated
Matt
 
You can use the WRITE-JSON method on the buffer-handle to write the output to a longchar:

Code:
DEFINE TEMP-TABLE tt
   FIELD cc AS CHAR.


DEF VAR lcc AS LONGCHAR.




CREATE tt. tt.cc = "hello world".


TEMP-TABLE tt:DEFAULT-BUFFER-HANDLE:WRITE-JSON( "longchar", lcc ).


MESSAGE STRING( lcc ) VIEW-AS ALERT-BOX.

Static streams are, just as static temp-tables, defined at program level, so cannot be scoped locally. You can however create a dynamic stream (see CREATE STREAM).
 
Back
Top