Forum Discussion
JustinM89
6 years agoContributor
You can extract the value from the JSON payload, cast it to an Integer, increment it, then re-set it in your JSON payload:
import groovy.json.* String json // Assuming this your JSON payload, wherever you get it from def map = new JsonSlurper().parseText(json)
Integer submissionId = Integer.parseInt(map.getAt('whatevs_submissionid')) + 1 // maybe wrap with try/catch here? map.putAt('whatevs_submissionid', submissionId.toString()) // Put it back in the map
json = new JsonBuilder(map).toPrettyString() // Map back to JSON
Is this what you're trying to accomplish?
Related Content
Recent Discussions
- 47 minutes ago
- 5 days ago
- 9 days ago