I am looking for more information about #PRIM_JSON.Document, more specifically about its SaveToFile feature.
I need to store request being sent to API and response coming back from API in a JSON format file. Currently both the request and response data is in the form of #PRIM_DC.Unicode string.
I am able to load string to #PRIM_JSON.Document type object but how do I save this document in a particular folder/directory?
Code sample:
Mthroutine Name(SaveRequest)
Define_Map For(*INPUT) Class(#STD_A50) Name(#Filename)
Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#RequestStr)
Define_Map For(*INPUT) Class(#STD_A512) Name(#InputUrl)
Define_Com Class(#XPRIM_JsonWriter) Name(#DocWriter)
Define_Com Class(#PRIM_DC.UnicodeString) Name(#Text)
Define_Com Class(#PRIM_JSON.Document) Name(#Doc)
#DocWriter.SetOutputToString String(#Text)
#DocWriter.BeginObject
#DocWriter.WriteString Name('URL') Value(#InputUrl)
#DocWriter.WriteString Name('RequestString') Value(#RequestStr.AsNativeString)
#DocWriter.EndObject
#Doc.LoadFromString Inputstring(#Text.AsNativeString)
#Filename := *DD_XML_PATH + #Filename
#Doc.SaveToFile // not sure how to use it
Endroutine
Could you please help me understand how do I save #Doc data to a particular location in json format?
Is there any other approach to save json file in lansa?