0

in the test I have to get the product version and build number but they are in different lines, and have an extra suffix that needs to be removed. I can not cope with this task, can you help?

JsonObject versionConfig = read("config","version",user.userName, user.password);
version=versionConfig.get("buildNumber").getAsString();

json answer

{
  "version": "1.1-SNAPSHOT",
  "branch": "1111",
  "buildNumber": "666",
  "date": "01.01.2020"
}

everyone understands what I am getting only version=666

but in the end I need to get

version=1.1.666

do not swear, I worked as a system administrator for 3 years, and I'm only learning Java, and with parsing, Json did not work at all, this is the best that I could

Null Echo
  • 3
  • 2

1 Answers1

0

You can get your version and replace "Version" by your buildNumber:

String version = versionConfig.get("version").getAsString();
String buildNumber = versionConfig.get("buildNumber").getAsString();
String result = version.replace("Version",buildNumber);
//1.1-Version => 1.1-666
IQbrod
  • 2,060
  • 1
  • 6
  • 28