当前位置: 首页>>代码示例>>Java>>正文


Java JsonGenerator.writeStartArray方法代码示例

本文整理汇总了Java中javax.json.stream.JsonGenerator.writeStartArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeStartArray方法的具体用法?Java JsonGenerator.writeStartArray怎么用?Java JsonGenerator.writeStartArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.json.stream.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.writeStartArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toJson

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
@Override
public void toJson(JsonGenerator generator) {
    generator.write("workflowId", workflowId);
    generator.writeStartArray("ruleIds");
    for (RuleId ruleId : ruleIds) {
        generator.writeStartObject();
        generator.write("attributeSet", ruleId.getAttributeSet().toString());
        generator.writeStartObject("securityIndexId");
        generator.write("contingencyId", ruleId.getSecurityIndexId().getContingencyId());
        generator.writeStartObject("securityIndexType");
        generator.write("name", ruleId.getSecurityIndexId().getSecurityIndexType().name());
        generator.write("label", ruleId.getSecurityIndexId().getSecurityIndexType().getLabel());
        generator.write("dynamic", ruleId.getSecurityIndexId().getSecurityIndexType().isDynamic());
        generator.writeEnd();
        generator.writeEnd();
        generator.writeEnd();
    }
    generator.writeEnd();
}
 
开发者ID:itesla,项目名称:ipst,代码行数:20,代码来源:SecurityRulesChangeMessage.java

示例2: toJson

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
@Override
public void toJson(JsonGenerator generator) {
    generator.write("workflowId", workflowId);
    generator.writeStartArray("samplesSynthesis");
    for (SampleSynthesis sample : samples) {
        generator.writeStartObject()
                    .write("id", sample.getId())
                    .writeStartObject("lastTaskEvent")
                        .write("type", sample.getLastTaskEvent().getTaskType().name())
                        .write("status", sample.getLastTaskEvent().getTaskStatus().name());
        if (sample.getLastTaskEvent().getFailureReason() != null) {
            generator.write("failureReason", sample.getLastTaskEvent().getFailureReason());
        }
        generator.writeEnd()
                .writeEnd();
    }
    generator.writeEnd();
}
 
开发者ID:itesla,项目名称:ipst,代码行数:19,代码来源:SamplesSynthesisMessage.java

示例3: 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();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:23,代码来源:InstanceBodyWriterTools.java

示例4: 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();
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:22,代码来源:ProjectLicense.java

示例5: 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();
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:22,代码来源:License.java

示例6: createString

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
public static String createString(Collection<Dependency> dependencies)
{
    TreeSet<Dependency> sortedDependencies = new TreeSet<>();
    sortedDependencies.addAll(dependencies);

    StringWriter jsonString = new StringWriter();
    JsonGenerator generator = Json.createGenerator(jsonString);
    generator.writeStartArray();
    for (Dependency dependency : sortedDependencies)
    {
        String license = dependency.getLicense();
        generator.writeStartObject();
        generator.write("name", dependency.getName());
        generator.write("version", dependency.getVersion());
        generator.write("license", license != null ? license : " ");
        generator.writeEnd();
    }
    generator.writeEnd();
    generator.close();
    return jsonString.toString();
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:22,代码来源:Dependency.java

示例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();
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:21,代码来源:MavenLicense.java

示例8: 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();
}
 
开发者ID:arisona,项目名称:ether,代码行数:19,代码来源:ScenarioWriter.java

示例9: testJsonValueJson

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
private void testJsonValueJson (String f) throws IOException
{
	File file = new File (f.replace ('/', File.separatorChar));

	JsonValue value;

	TextJsonParser p = getJsonParser (file);
	p.next ();
	value = p.getValue ();
	p.close ();

	StringWriter out1 = new StringWriter ();
	JsonGenerator g1 = new TextJsonGenerator (out1);
	g1.writeStartArray ();
	g1.write (value);
	g1.writeEnd ();
	g1.close ();

	JsonProvider provider = new org.glassfish.json.JsonProviderImpl ();
	StringWriter out2 = new StringWriter ();
	JsonGenerator g2 = provider.createGenerator (out2);
	g2.writeStartArray ();
	g2.write (value);
	g2.writeEnd ();
	g2.close ();

	Assert.assertEquals (out1.toString (), out2.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:29,代码来源:TextJsonGeneratorTest.java

示例10: toJson

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
@Override
public void toJson(JsonGenerator generator) {
    generator.writeStartArray("countries");
    for (Country country : countries) {
        generator.writeStartObject();
        generator.write("id", country.name());
        generator.write("label", country.name() + ", " + country.getName());
        generator.writeEnd();
    }
    generator.writeEnd();
}
 
开发者ID:itesla,项目名称:ipst,代码行数:12,代码来源:CountriesMessage.java

示例11: 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();
}
 
开发者ID:itesla,项目名称:ipst,代码行数:16,代码来源:BusyCoresSeriesMessage.java

示例12: testJsonValueBson

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
private void testJsonValueBson (String f) throws IOException
{
	File file = new File (f.replace ('/', File.separatorChar));

	JsonValue value;

	BsonParser p = new BsonParser (new FileInputStream (file));
	p.setRootAsArray (true);
	p.next ();
	value = p.getValue ();
	p.close ();

	StringWriter out1 = new StringWriter ();
	JsonGenerator g1 = new TextJsonGenerator (out1);
	g1.writeStartArray ();
	g1.write (value);
	g1.writeEnd ();
	g1.close ();

	JsonProvider provider = new org.glassfish.json.JsonProviderImpl ();
	StringWriter out2 = new StringWriter ();
	JsonGenerator g2 = provider.createGenerator (out2);
	g2.writeStartArray ();
	g2.write (value);
	g2.writeEnd ();
	g2.close ();

	Assert.assertEquals (out1.toString (), out2.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:30,代码来源:TextJsonGeneratorTest.java

示例13: writeTo

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeTo(InstanceCollection instanceCollection, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws UnsupportedEncodingException {
    String charSet = "UTF-8";
    JsonGenerator jg = Json.createGenerator(new OutputStreamWriter(entityStream, charSet));
    jg.writeStartArray();

    Matrix4d gM = new Matrix4d();
    gM.setIdentity();
    InstanceBodyWriterTools.generateInstanceStreamWithGlobalMatrix(productService, null, gM, instanceCollection, new ArrayList<>(), jg);
    jg.writeEnd();
    jg.flush();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:13,代码来源:InstanceCollectionMessageBodyWriter.java

示例14: writeMatrix

import javax.json.stream.JsonGenerator; //导入方法依赖的package包/类
private static void writeMatrix(Matrix4d matrix, JsonGenerator jg) {
    jg.writeStartArray("matrix");
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            jg.write(matrix.getElement(i, j));
        }
    }
    jg.writeEnd();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:10,代码来源:InstanceBodyWriterTools.java

示例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();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:12,代码来源:InstanceBodyWriterTools.java


注:本文中的javax.json.stream.JsonGenerator.writeStartArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。