Skip to content

Instantly share code, notes, and snippets.

@menski
Last active August 29, 2015 14:05
Show Gist options
  • Save menski/3f2a3eb75a6d843075a5 to your computer and use it in GitHub Desktop.
Save menski/3f2a3eb75a6d843075a5 to your computer and use it in GitHub Desktop.
camunda Spin JSON support
// read JSON from String
SpinJsonNode json = JSON("{\"name\": \"camunda\", \"version\": \"7.2.0-alpha3\"}");
// read JSON object property as String
String version = json.prop("version").stringValue();
// calculate new version
int newVersion = Integer.valueOf(version.substring(version.length() - 1)) + 1;
version = version.substring(0, version.length() - 1 ) + newVersion;
// set JSON object property
json.prop("version", version);
// return JSON as String
System.out.println(json.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment