def map = [:]
map.put('name', 'rayscott')
map.put('hip', false)
builder = new groovy.json.JsonBuilder(map)
builder.toString()
{"requestId":"352939bd-7a5c-4f1b-828d-ea667dc96570","status":{"message":"","code":200,"attributes":{}},"result":{"data":["{\"name\":\"rayscott\",\"hip\":false}"],"meta":{}}}
["{\"name\":\"rayscott\",\"hip\":false}"]
{"name":"rayscott","hip":false}
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/5bab8ce4-c5cd-4fee-b7c9-91bb2f800592%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Gremlin Server converts all results to iterators so even a returned String becomes a SingleIterator with one item in it.
On Thu, Nov 2, 2017 at 1:46 PM, 'Ray Scott' via Gremlin-users <gremli...@googlegroups.com> wrote:
Hi,Attempting to generate JSON from a Groovy script submitted to GS. My hold on Groovy is almost non-existent. However, what is happening doesn't seem to add up.def map = [:]
map.put('name', 'rayscott')
map.put('hip', false)
builder = new groovy.json.JsonBuilder(map)
builder.toString()
If I submit this script, the data that is returned is wrapped as an array...{"requestId":"352939bd-7a5c-4f1b-828d-ea667dc96570","status":{"message":"","code":200,"attributes":{}},"result":{"data":["{\"name\":\"rayscott\",\"hip\":false}"],"meta":{}}}
data =["{\"name\":\"rayscott\",\"hip\":false}"]
I have to pull the JSON out of the array to get what I really want...{"name":"rayscott","hip":false}Does anyone know why this happens, and/or how to stop its from happening?My end goal here is to return JSON formatted data back from the server. I've tried JsonOutput, JsonBuilder.getContent, but what is generated is unusable.Thanks.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.