...
Navigate to
Workbench
. The ad-hoc pipeline editor opens.Replace the existing content by this pipeline:
Code Block language yaml pipeline: - drive.read: path: "person.json"
RUN the pipeline and you should see the content of the file
person.json
as output:Code Block language json { "firstName": "Marissa", "lastName": "Smith", "age": 33 }
This is because the file is automatically converted from a content object to its the mime type format - which is JSON in this case - and then sent to the client.
In order to “see” the content object and not the result, change the pipeline to this:
Code Block language yaml pipeline: - drive.read: path: "person.json" - set.body: value: "#{@convert.toJson(body)}"
RUN the pipeline and you should see as output the content object with meta information about the file:
Code Block language json { "name": "person.json", "created": 1637045518731, "lastUpdated": null, "size": 64, "data": "ewogICJmaXJzdE5hbWUiOiAiTWFyaXNzYSIs...", "mimeType": "application/json" }
...
In case you want to work with the JSON data of a file, the data part of the content object is the interesting thing for you. In order to load this into the body, again use the @convert.toJson()
but this time point to the data property:
Code Block | ||
---|---|---|
| ||
pipeline: - drive.read: path: "person.json" - set.body: value: "#{@convert.toJson(body.data)}" |
...
You should see an output similar to this, which transformed the JSON:
Code Block | ||
---|---|---|
| ||
"Full name: Marissa Smith" |
...