Survey Data is of a userdefined type (de.aristaflow.adept2.model.datamanagement.UDTValue) with the name application/json generated by the survey environment. It is comparable to a BLOB in a database which we cannot interpret and so assume it's a UTF-8 string as byte heaps.
The data format of the survey data can be examined more closely via the process visualisation as follows and can be extracted to a file. The survey data looks like a JsonArray but it is not of the type org.json.JSONObject, nor can it be treated directly like a JsonObject.
Access to certain Survey Data values¶
As already mentioned in the chapter Parameterhandling, survey data contains all data from a survey form and can be an input or output parameter of a survey activity. However, if you do not want to read or write the entire survey, but only individual values from the Survey Data, we need certain intermediate steps. The Survey Data is of type application/json and this is a user-defined type (UDT). Since UDTs can contain anything, they are treated as black boxes and provided by InputStreams. To get the value of the Survey Data as an InputStream, use the interface getValueAsStream(). To get the value as a byte array, use getValueAsArray(). Individual survey data values can be accessed in a script activity using these methods.
def slurper = new groovy.json.JsonSlurper(); def convertedSurveyData = $surveyData.getValueAsStream().getText(); $Adress = slurper.parseText(convertedSurveyData).Adress;
var javaString = new java.lang.String($surveyData.getValueAsArray(), "utf-8"); var jsonObject = JSON.parse(javaString); $Adress = jsonObject.Adress;