Questions tagged [jsonbuilder]
78 questions
0
votes
1 answer
groovy json builder json.call - to combine single Json output
I have two ArrayList and I need to print in JSON format. I used the below code to print the ArrayList as JSON string
def a = ['R1','R2']
def b = ['R3','R4']
def json = new groovy.json.JsonBuilder()
json set1: a
println…

Prabu
- 3,550
- 9
- 44
- 85
0
votes
1 answer
Capture json.builder data in a variable
I have a function in controller file in which we are rendering response at the end of the function like this:
render_response(template: 'index')
render_response is a custom function in a separate helper file defined like this:
def…

Bhawan
- 2,441
- 3
- 22
- 47
0
votes
2 answers
Generate JSON object in Groovy
For some reason I am not able to create JSON object in Groovy using JSONBuilder
Here is what I have but it comes back {}:
import groovy.json.JsonBuilder
JsonBuilder builder = new JsonBuilder()
builder {
name "Name"
description…

Angelina
- 2,175
- 10
- 42
- 82
0
votes
1 answer
@JsonbTypeDeserializer and @JsonbTypeSerializer don't work in the fields
I'm in an activity of exchanging Jackson for Jsob-B and I am having a problem on use @JsonbTypeDeserializer and @JsonbTypeSerializer as told below.
I have an entity like this:
public class User implements Serializable {
private static final long…

Luciano Borges
- 817
- 3
- 12
- 31
0
votes
1 answer
Serialize java.nio.file.Path with JsonBuilder in Groovy
I am trying to serialize an object which holds an instance of java.nio.file.Path and since path is an interface I am receiving a StackOverflow Exception
I have checked this answer: https://stackoverflow.com/a/36966590/11325201
and wanted to…

Ethan K
- 131
- 1
- 9
0
votes
1 answer
How to construct json key contains dot
JsonBuilder
Script does not work when json key has dot. Works well when key does not contains dot.
security.set(data.getValue('set', index).toBoolean())
I want the output json like
"security.set": true

user2201789
- 1,083
- 2
- 20
- 45
0
votes
1 answer
How to Generate an Array of Objects with Nested Siblings with Groovy JsonBuilder
I'm trying to generate a JSON array with multiple nested objects.
Here's what I'd like to generate: (shortened output since I want an array, this just repeats if you run the code):
[
{
"User": {
"Name": "Foo",
…

Ian Dallas
- 12,451
- 19
- 58
- 82
0
votes
1 answer
jsonBuilder without indexes
I tried the example described here: http://docs.groovy-lang.org/2.4.7/html/gapi/groovy/json/JsonBuilder.html
this works great but how can I generate a json payload where some items do not have indexes such as "firstElt" and "secondElt" in this…

laloune
- 548
- 1
- 9
- 26
0
votes
1 answer
Groovy unable to generate json output as needed
I'm trying to generate the following JSON output in Groovy for one of my Jenkins Job.
Expected JSON
{
"svc-a": {
"type": "object",
"properties": {
"svcVersion": {
"type": "string",
…

Pasha
- 170
- 1
- 19
0
votes
1 answer
JSON Builder to access variable inside JSON array
I want to change the value of 'action' to "1".
Currently my code is as follows.
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
def slurped = new JsonSlurper().parseText(vars.get("reqApproval"))
def builder = new…

Joe Tobin
- 482
- 3
- 12
0
votes
2 answers
Groovy No such property error while creating dynamic json
I am trying to create a dynamic json using csv data in jmeter with JSR223 PreProcessor
Below is the code for the same I am using CSV for data for Id and Name:
def builder = new groovy.json.JsonBuilder()
@groovy.transform.Immutable
class Items {
…

shashank shukla
- 65
- 8
0
votes
2 answers
JsonOutput.toJson using a JsonBuilder object adds additional "content" element
I'm using JsonBuilder to create a new Json object. Additionally I have to do an escaping of control and special charaters.
Therefore I'm using the JsonOutput.toJson which adds an additional "content" element.
sample XML input:

Marco
- 25
- 2
- 6
0
votes
1 answer
Using json builder
I want something like this in my application with json builder
new JsonBuilder() {
persons.collect{
[
name: it.name,
age: it.age,
companies: [{
…

xxx
- 11
- 4
0
votes
2 answers
Groovy JSON array builder with custom members inside of closure
I am going to create simple JSON array from my items list. I have found great sample how to do it with JsonBuilder. It looks like:
class Author {
String name
}
def authors = [new Author (name: "Guillaume"),
new Author (name:…

RredCat
- 5,259
- 5
- 60
- 100
0
votes
2 answers
Build JSON with multiple arrays in Groovy
Can anyone please help me in building JSON in the format below?
{
"hid": 5000607,
"eid": "mpuli243",
"lud": 1488299449000,
"ats": [{
"ac": ["CCLA0004"],
"lud": 1488296135092,
"prem": "Y",
"pr": [{
…

manoj pulipati
- 1
- 1