List of usage examples for javax.json.stream JsonGenerator writeStartArray
JsonGenerator writeStartArray();
From source file:at.porscheinformatik.sonarqube.licensecheck.mavenlicense.MavenLicense.java
public static String createString(Collection<MavenLicense> mavenLicenses) { TreeSet<MavenLicense> mavenLicenseSet = new TreeSet<>(); mavenLicenseSet.addAll(mavenLicenses); StringWriter jsonString = new StringWriter(); JsonGenerator generator = Json.createGenerator(jsonString); generator.writeStartArray(); for (MavenLicense mavenLicense : mavenLicenseSet) { generator.writeStartObject();//from w ww .java2s. com generator.write("licenseNameRegEx", mavenLicense.getLicenseNameRegEx().pattern()); generator.write("license", mavenLicense.getLicense()); generator.writeEnd(); } generator.writeEnd(); generator.close(); return jsonString.toString(); }
From source file:at.porscheinformatik.sonarqube.licensecheck.license.License.java
public static String createString(Collection<License> licenses) { TreeSet<License> licenseSet = new TreeSet<>(); licenseSet.addAll(licenses);//from ww w .j a v a 2 s.co m StringWriter jsonString = new StringWriter(); JsonGenerator generator = Json.createGenerator(jsonString); generator.writeStartArray(); for (License license : licenseSet) { generator.writeStartObject(); generator.write("name", license.getName()); generator.write("identifier", license.getIdentifier()); generator.write("status", license.getStatus()); generator.writeEnd(); } generator.writeEnd(); generator.close(); return jsonString.toString(); }