Questions tagged [jsonbuilder]

78 questions
3
votes
1 answer

How to modify JSON in groovy

I use JsonBuilder to build a JSONObject/String. But, how can I update/change value of one field in this JSONObject/String? I am not seeing the possibility of doing this using JsonBuilder. What show I use then?
user1947415
  • 933
  • 4
  • 14
  • 31
2
votes
1 answer

Store multiple key:value pairs inside json object

I am very new with groovy scripts. I would like to build a JSON output using responses from an api that I query. Since I want to build the JSON file dynamically over multiple queries, I am using a map. I want to store multiple key:value pairs in a…
Zepperoni
  • 23
  • 3
2
votes
2 answers

Manipulate ArrayNode to be used as JsonBuilder parameter in Groovy

I'm trying to execute an Orchestration that retrieves a set of information from the server site and I want to manipulate the output in order to get only the necessary data. The Output's manipulation menu, allow me to handle it via Groovy…
Marce
  • 91
  • 1
  • 7
2
votes
1 answer

How to use jsonbuilder to make a json which has a key named like a DefaultGroovyMethods method (identity)?

def builder = new groovy.json.JsonBuilder() def root = builder.auth { identity { methods (['password']) password { user { name { …
Florin B
  • 23
  • 5
2
votes
1 answer

Strip out quotes from integer in JSON Builder

I need to run the groovy scripts below to build a JSON template. The issue i am running into is that the integer in the template is surrounded in quotes. Stripping out the quotes from the variables treats it like a string. cat port.txt 1001 Here is…
crusadecoder
  • 651
  • 1
  • 11
  • 26
2
votes
1 answer

Rails 5 in API mode only returning id, created_at, and updated_at of a record

I am using Rails 5 in API mode. On querying my server for a resource, I only receive the ID, created_at, and updated_at attributes of my resource. Everything seems fine when I query it directly from the rails console: >> GoodThing.find 2 GoodThing…
aethos
  • 45
  • 4
2
votes
2 answers

How can I create a two-element object with Groovy's JsonBuilder?

In my Groovy code, I've got two variables declared: results is an array of maps. It contains a list of rows returned from a SQL query. overall is a map. It represents a single row of a separate SQL query. I want to combine these two variables into…
soapergem
  • 9,263
  • 18
  • 96
  • 152
2
votes
1 answer

How to keep timezones when using Groovy's JsonBuilder?

Groovy's JsonBuilder does not seem to transform timezones in dates to JSON string at all. Or more precisely, it uses GMT always. For example the following code should print the date as midnight of 2001-02-03, GMT +2. But instead, it prints…
kaskelotti
  • 4,709
  • 9
  • 45
  • 72
2
votes
1 answer

Groovy JsonBuilder call methods to add information

The following code works fine def json = new JsonBuilder() json { writeNumbers(delegate, "myNumbers") } println json.toPrettyString() def writeNumbers(json, name) { json."$name" { "w" 32 "h" 32 } } But as soon as I move or add…
Nicolas Martel
  • 1,641
  • 3
  • 19
  • 34
2
votes
1 answer

Setting delegate value with Groovy JsonBuilder

(This is a follow up question to a question asked here) I'm using Groovy's JsonBuilder to dynamically generate the following JSON: { "type": { "__type": "urn", "value": "myCustomValue1" }, "urn": { "__type":…
Devin
  • 1,014
  • 1
  • 9
  • 28
1
vote
0 answers

JSON to BSON conversion - Java Library

Are there any readily available Java Libraries, which are useful in converting JSON to BSON format. List of Java libraries, which are useful in converting JSON to BSON format.
Ranga
  • 11
  • 4
1
vote
1 answer

Groovy Transform json nested Structure to jsonobject from array

the input is { "Id": ["A1", "A2", "A3"], "isAvailable": true, "isActive": true } the output should be like { "Id": "A1", "isAvailable": true, "isActive": true }, { "Id": "A2", "isAvailable": true, "isActive": true }, { "Id":…
coochiman
  • 13
  • 3
1
vote
2 answers

Preparing JSON array of Objects from multiple array list

I am very new to the Groovy scripts and would like to build a JSON output from the below JSON input. Kindly help! My JSON input looks like this: { "id":"1222", "storageNode": { "uuid": "22255566336", "properties": { "BuinessUnit":…
Praloy
  • 13
  • 4
1
vote
1 answer

JMeter - Cannot Get Dynamics CSV Values Into My JsonBuilder Request Body

I asked a question yesterday about creating a dynamic request body with pre-processors on JMeter. Thanks to Dmitri T, I almost got what I wanted. Old question here: JMeter Creating a Pre-Processor that will generate a request body based on a user…
Gökhan Uçar
  • 191
  • 15
1
vote
0 answers

Groovy 3 and use of underscore with JsonBuilder

I have the following code that works with Groovy 2.5.7: import groovy.json.JsonBuilder def name = "foo" def builder = new JsonBuilder() builder { _id name contactInformation { telephoneNumber("12345") …
Bob
  • 11
  • 1