本文整理匯總了Java中javax.json.stream.JsonGenerator.writeStartObject方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.writeStartObject方法的具體用法?Java JsonGenerator.writeStartObject怎麽用?Java JsonGenerator.writeStartObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.json.stream.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeStartObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: statementNotAllowedBuild
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
/**
* Builds a security error message in JSON format for Statements
* @param sqlOrder
* @param errorMessage
* @param doPrettyPrinting
* @return
*/
public static String statementNotAllowedBuild(String sqlOrder, String errorMessage, boolean doPrettyPrinting) {
try {
JsonGeneratorFactory jf = JsonUtil
.getJsonGeneratorFactory(doPrettyPrinting);
ByteArrayOutputStream out = new ByteArrayOutputStream();
JsonGenerator gen = jf.createGenerator(out);
gen.writeStartObject();
gen.write(Tag.PRODUCT_SECURITY, errorMessage);
gen.write("SQL order", sqlOrder);
gen.writeEnd();
gen.close();
return out.toString("UTF-8");
} catch (Exception e) {
String returnString = Tag.PRODUCT_SECURITY + " " + errorMessage
+ " " + sqlOrder;
return returnString;
}
}
示例2: writeBuilding
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
void writeBuilding(JsonGenerator gen, Building b) {
gen.writeStartObject();
gen.write("id", b.getId());
gen.write("type", b.getType().toString());
gen.write("height", b.getFinalHeight());
gen.write("line", b.getLine().toString());
gen.write("setback", b.getSetback().toString());
gen.write("use", b.getUse().toString());
writeVectorList(gen, "lot", b.getLot().asList());
gen.writeStartArray("plan");
for (Polygon p : b.getPlan()) {
gen.writeStartObject();
writeVectorList(gen, "polygon", p.asList());
gen.writeEnd();
}
gen.writeEnd();
gen.writeEnd();
}
示例3: writeLeaf
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
private static void writeLeaf(List<PartLink> currentPath, List<Integer> copyInstanceIds, PartIteration partI, Matrix4d combinedMatrix, JsonGenerator jg) {
String partIterationId = partI.toString();
List<InstanceAttributeDTO> attributes = new ArrayList<>();
for (InstanceAttribute attr : partI.getInstanceAttributes()) {
attributes.add(mapper.map(attr, InstanceAttributeDTO.class));
}
jg.writeStartObject();
jg.write("id", Tools.getPathInstanceAsString(currentPath, copyInstanceIds));
jg.write("partIterationId", partIterationId);
jg.write("path", Tools.getPathAsString(currentPath));
writeMatrix(combinedMatrix, jg);
writeGeometries(partI.getSortedGeometries(), jg);
writeAttributes(attributes, jg);
jg.writeEnd();
jg.flush();
}
示例4: writeGeometries
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
private static void writeGeometries(List<Geometry> files, JsonGenerator jg) {
jg.write("qualities", files.size());
if (!files.isEmpty()) {
Geometry geometry = files.get(0);
jg.write("xMin", geometry.getxMin());
jg.write("yMin", geometry.getyMin());
jg.write("zMin", geometry.getzMin());
jg.write("xMax", geometry.getxMax());
jg.write("yMax", geometry.getyMax());
jg.write("zMax", geometry.getzMax());
}
jg.writeStartArray("files");
for (Geometry g : files) {
jg.writeStartObject();
jg.write("fullName", "api/files/" + g.getFullName());
jg.writeEnd();
}
jg.writeEnd();
}
示例5: createString
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
public static String createString(Collection<ProjectLicense> projectLicenses)
{
TreeSet<ProjectLicense> projectLicenseSet = new TreeSet<>();
projectLicenseSet.addAll(projectLicenses);
StringWriter jsonString = new StringWriter();
JsonGenerator generator = Json.createGenerator(jsonString);
generator.writeStartArray();
for (ProjectLicense projectLicense : projectLicenseSet)
{
generator.writeStartObject();
generator.write("projectKey", projectLicense.getProjectKey());
generator.write("license", projectLicense.getLicense());
generator.write("status", projectLicense.getStatus());
generator.writeEnd();
}
generator.writeEnd();
generator.close();
return jsonString.toString();
}
示例6: createString
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
public static String createString(Collection<License> licenses)
{
TreeSet<License> licenseSet = new TreeSet<>();
licenseSet.addAll(licenses);
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();
}
示例7: createString
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
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();
generator.write("regex", mavenLicense.getRegex().pattern());
generator.write("license", mavenLicense.getLicense());
generator.writeEnd();
}
generator.writeEnd();
generator.close();
return jsonString.toString();
}
示例8: serialize
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Book book, JsonGenerator generator, SerializationContext ctx) {
if (book != null) {
generator.writeStartObject();
ctx.serialize(book.getClass().getName(), book, generator);
generator.writeEnd();
} else {
ctx.serialize(null, generator);
}
}
示例9: serialize
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Magazine magazine, JsonGenerator generator, SerializationContext ctx) {
if (magazine != null) {
generator.writeStartObject();
ctx.serialize("name", magazine.getAuthor(), generator);
generator.writeEnd();
} else {
ctx.serialize(null, generator);
}
}
示例10: serialize
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Book book, JsonGenerator generator, SerializationContext ctx) {
generator.writeStartObject();
generator.write("id", "QWE-123-RTS");
generator.write("title", book.getTitle());
generator.write("firstName", book.getAuthor().split(" ")[0]);
generator.write("lastName", book.getAuthor().split(" ")[1]);
generator.writeEnd();
}
示例11: serialize
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(final CoffeeEvent event, final JsonGenerator generator, final SerializationContext ctx) {
generator.write("class", event.getClass().getCanonicalName());
generator.writeStartObject("data");
ctx.serialize("data", event, generator);
generator.writeEnd();
}
示例12: serialize
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Crate obj, JsonGenerator generator, SerializationContext ctx) {
generator.writeStartObject();
generator.write("crateStr", "REPLACED crate str");
ctx.serialize("crateInner", obj.crateInner, generator);
ctx.serialize("crateInnerList", obj.crateInnerList, generator);
generator.write("crateBigDec", new BigDecimal("54321"));
generator.writeEnd();
}
示例13: writeOpenSpace
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
void writeOpenSpace(JsonGenerator gen, OpenSpaceBlock b) {
gen.writeStartObject();
gen.write("id", b.getId());
gen.write("type", b.getOpenSpaceType().toString());
writeVectorList(gen, "polygon", b.getShape().asList());
writeVectorList(gen, "shrubs", b.getShrubPositions());
writeVectorList(gen, "trees", b.getTreePositions());
gen.writeEnd();
}
示例14: toJson
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void toJson(JsonGenerator generator) {
generator.writeStartObject("busyCoresSeries");
generator.write("availableCores", busyCoresSeries.getAvailableCores());
generator.writeStartArray("values");
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/YYYY HH:mm:ss");
for (BusyCoresSeries.Value value : busyCoresSeries.getValues()) {
generator.writeStartObject()
.write("date", value.getDate().toString(fmt))
.write("busyCores", value.getBusyCores())
.writeEnd();
}
generator.writeEnd()
.writeEnd();
}
示例15: writeAttributes
import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
private static void writeAttributes(List<InstanceAttributeDTO> attributes, JsonGenerator jg) {
jg.writeStartArray("attributes");
for (InstanceAttributeDTO a : attributes) {
jg.writeStartObject();
jg.write("name", a.getName());
jg.write("type", a.getType().toString());
jg.write("value", a.getValue());
jg.writeEnd();
}
jg.writeEnd();
}