Example usage for com.fasterxml.jackson.core JsonGenerator writeStartArray

List of usage examples for com.fasterxml.jackson.core JsonGenerator writeStartArray

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator writeStartArray.

Prototype

public abstract void writeStartArray() throws IOException, JsonGenerationException;

Source Link

Document

Method for writing starting marker of a JSON Array value (character '['; plus possible white space decoration if pretty-printing is enabled).

Usage

From source file:eu.project.ttc.models.index.JsonTermIndexIO.java

public static void save(Writer writer, TermIndex termIndex, JsonOptions options) throws IOException {
    JsonFactory jsonFactory = new JsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory 
    //      jsonFactory.configure(f, state)
    JsonGenerator jg = jsonFactory.createGenerator(writer); // or Stream, Reader
    jg.useDefaultPrettyPrinter();/*  ww w.j  a  v a  2  s  .  co  m*/

    jg.writeStartObject();

    jg.writeFieldName(METADATA);
    jg.writeStartObject();
    jg.writeFieldName(NAME);
    jg.writeString(termIndex.getName());
    jg.writeFieldName(LANG);
    jg.writeString(termIndex.getLang().getCode());
    if (termIndex.getCorpusId() != null) {
        jg.writeFieldName(CORPUS_ID);
        jg.writeString(termIndex.getCorpusId());
    }

    jg.writeFieldName(OCCURRENCE_STORAGE);
    if (options.isMongoDBOccStore()) {
        jg.writeString(OCCURRENCE_STORAGE_MONGODB);
        jg.writeFieldName(OCCURRENCE_MONGODB_STORE_URI);
        jg.writeString(options.getMongoDBOccStore());
    } else if (options.isEmbeddedOccurrences())
        jg.writeString(OCCURRENCE_STORAGE_EMBEDDED);
    else
        throw new IllegalStateException("Unknown storage mode");

    jg.writeFieldName(NB_WORD_ANNOTATIONS);
    jg.writeNumber(termIndex.getWordAnnotationsNum());
    jg.writeFieldName(NB_SPOTTED_TERMS);
    jg.writeNumber(termIndex.getSpottedTermsNum());

    jg.writeEndObject();

    jg.writeFieldName(INPUT_SOURCES);
    int idCnt = 0;
    Map<String, Integer> inputSources = Maps.newTreeMap();
    for (Document d : termIndex.getDocuments())
        if (!inputSources.containsKey(d.getUrl()))
            inputSources.put(d.getUrl(), ++idCnt);
    jg.writeStartObject();
    for (String uri : inputSources.keySet()) {
        jg.writeFieldName(inputSources.get(uri).toString());
        jg.writeString(uri);
    }
    jg.writeEndObject();

    jg.writeFieldName(WORDS);
    jg.writeStartArray();
    for (Word w : termIndex.getWords()) {
        jg.writeStartObject();
        jg.writeFieldName(LEMMA);
        jg.writeString(w.getLemma());
        jg.writeFieldName(STEM);
        jg.writeString(w.getStem());
        if (w.isCompound()) {
            jg.writeFieldName(COMPOUND_TYPE);
            jg.writeString(w.getCompoundType().name());
            jg.writeFieldName(COMPONENTS);
            jg.writeStartArray();
            for (Component c : w.getComponents()) {
                jg.writeStartObject();
                jg.writeFieldName(LEMMA);
                jg.writeString(c.getLemma());
                jg.writeFieldName(BEGIN);
                jg.writeNumber(c.getBegin());
                jg.writeFieldName(END);
                jg.writeNumber(c.getEnd());
                jg.writeEndObject();
            }
            jg.writeEndArray();
        }

        jg.writeEndObject();
    }
    jg.writeEndArray();

    Set<TermVariation> termVariations = Sets.newHashSet();

    jg.writeFieldName(TERMS);
    jg.writeStartArray();
    for (Term t : termIndex.getTerms()) {
        termVariations.addAll(t.getVariations());

        jg.writeStartObject();
        jg.writeFieldName(ID);
        jg.writeNumber(t.getId());
        jg.writeFieldName(RANK);
        jg.writeNumber(t.getRank());
        jg.writeFieldName(GROUPING_KEY);
        jg.writeString(t.getGroupingKey());
        jg.writeFieldName(WORDS);
        jg.writeStartArray();
        for (TermWord tw : t.getWords()) {
            jg.writeStartObject();
            jg.writeFieldName(SYN);
            jg.writeString(tw.getSyntacticLabel());
            jg.writeFieldName(LEMMA);
            jg.writeString(tw.getWord().getLemma());
            jg.writeEndObject();
        }
        jg.writeEndArray();

        jg.writeFieldName(FREQUENCY);
        jg.writeNumber(t.getFrequency());
        jg.writeFieldName(FREQ_NORM);
        jg.writeNumber(t.getFrequencyNorm());
        jg.writeFieldName(GENERAL_FREQ_NORM);
        jg.writeNumber(t.getGeneralFrequencyNorm());
        jg.writeFieldName(SPECIFICITY);
        jg.writeNumber(t.getSpecificity());
        jg.writeFieldName(SPOTTING_RULE);
        jg.writeString(t.getSpottingRule());

        if (options.withOccurrences() && options.isEmbeddedOccurrences()) {
            jg.writeFieldName(OCCURRENCES);
            jg.writeStartArray();
            for (TermOccurrence termOcc : t.getOccurrences()) {
                jg.writeStartObject();
                jg.writeFieldName(BEGIN);
                jg.writeNumber(termOcc.getBegin());
                jg.writeFieldName(END);
                jg.writeNumber(termOcc.getEnd());
                jg.writeFieldName(TEXT);
                jg.writeString(termOcc.getCoveredText());
                jg.writeFieldName(FILE);
                jg.writeNumber(inputSources.get(termOcc.getSourceDocument().getUrl()));
                jg.writeEndObject();
            }
            jg.writeEndArray();
        }

        if (options.isWithContexts() && t.isContextVectorComputed()) {
            jg.writeFieldName(CONTEXT);
            jg.writeStartObject();

            jg.writeFieldName(TOTAL_COOCCURRENCES);
            jg.writeNumber(t.getContextVector().getTotalCoccurrences());
            jg.writeFieldName(CO_OCCURRENCES);
            jg.writeStartArray();
            if (t.isContextVectorComputed()) {
                for (ContextVector.Entry contextEntry : t.getContextVector().getEntries()) {
                    jg.writeStartObject();
                    jg.writeFieldName(CO_TERM);
                    jg.writeString(contextEntry.getCoTerm().getGroupingKey());
                    jg.writeFieldName(NB_COCCS);
                    jg.writeNumber(contextEntry.getNbCooccs());
                    jg.writeFieldName(ASSOC_RATE);
                    jg.writeNumber(contextEntry.getAssocRate());
                    jg.writeEndObject();
                }
            }
            jg.writeEndArray();
            jg.writeEndObject();
        }

        jg.writeEndObject();
    }
    jg.writeEndArray();

    /* Variants */
    jg.writeFieldName(TERM_VARIATIONS);
    jg.writeStartArray();
    for (TermVariation v : termVariations) {
        jg.writeStartObject();
        jg.writeFieldName(BASE);
        jg.writeString(v.getBase().getGroupingKey());
        jg.writeFieldName(VARIANT);
        jg.writeString(v.getVariant().getGroupingKey());
        jg.writeFieldName(VARIANT_TYPE);
        jg.writeString(v.getVariationType().getShortName());
        jg.writeFieldName(INFO);
        jg.writeString(v.getInfo().toString());
        jg.writeFieldName(VARIANT_SCORE);
        jg.writeNumber(v.getScore());
        jg.writeEndObject();
    }
    jg.writeEndArray();

    jg.writeEndObject();
    jg.close();
}

From source file:net.opentsdb.contrib.tsquare.web.view.GraphiteJsonResponseWriter.java

@Override
public void write(final AnnotatedDataPoints annotatedPoints, final ResponseContext context) throws IOException {
    final JsonGenerator jsonGenerator = getJsonGenerator(context);

    jsonGenerator.writeStartObject();//from  w  ww.ja  va  2 s .  c o  m
    jsonGenerator.writeStringField("target", annotatedPoints.getDataPoints().metricName());

    if (includeAllTags) {
        jsonGenerator.writeArrayFieldStart("tags");
        for (final Map.Entry<String, String> entry : annotatedPoints.getDataPoints().getTags().entrySet()) {
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField("key", entry.getKey());
            jsonGenerator.writeStringField("value", entry.getValue());
            jsonGenerator.writeEndObject();
        }
        jsonGenerator.writeEndArray();
    }

    if (includeAggregatedTags) {
        jsonGenerator.writeArrayFieldStart("aggregatedTags");
        for (final String tag : annotatedPoints.getDataPoints().getAggregatedTags()) {
            jsonGenerator.writeString(tag);
        }
        jsonGenerator.writeEndArray();
    }

    if (summarize) {
        final DataPointsAsDoubles doubles = new DataPointsAsDoubles(annotatedPoints.getDataPoints());
        final double aggValue = Aggregators.SUM.runDouble(doubles);
        jsonGenerator.writeNumberField("summarizedValue", aggValue);
    } else {
        jsonGenerator.writeArrayFieldStart("datapoints");

        for (final DataPoint p : annotatedPoints.getDataPoints()) {
            jsonGenerator.writeStartArray();

            if (p.isInteger()) {
                jsonGenerator.writeNumber(p.longValue());
            } else {
                jsonGenerator.writeNumber(p.doubleValue());
            }

            if (isMillisecondResolution()) {
                jsonGenerator.writeNumber(p.timestamp());
            } else {
                jsonGenerator.writeNumber(TimeUnit.MILLISECONDS.toSeconds(p.timestamp()));
            }

            jsonGenerator.writeEndArray();
        }

        jsonGenerator.writeEndArray();
    }

    jsonGenerator.writeEndObject();
}

From source file:org.eclipse.winery.repository.resources.entitytypes.relationshiptypes.VisualAppearanceResource.java

@GET
@RestDoc(methodDescription = "@return JSON object to be used at jsPlumb.registerConnectionType('NAME', <data>)")
@Produces(MediaType.APPLICATION_JSON)//from ww w . j  a  va 2s  . c  o  m
public Response getConnectionTypeForJsPlumbData() {
    JsonFactory jsonFactory = new JsonFactory();
    StringWriter sw = new StringWriter();
    try {
        JsonGenerator jg = jsonFactory.createGenerator(sw);
        jg.writeStartObject();

        jg.writeFieldName("connector");
        jg.writeString("Flowchart");

        jg.writeFieldName("paintStyle");
        jg.writeStartObject();
        jg.writeFieldName("lineWidth");
        jg.writeNumber(this.getLineWidth());
        jg.writeFieldName("strokeStyle");
        jg.writeObject(this.getColor());
        String dash = this.getDash();
        if (!StringUtils.isEmpty(dash)) {
            String dashStyle = null;
            switch (dash) {
            case "dotted":
                dashStyle = "1 5";
                break;
            case "dotted2":
                dashStyle = "3 4";
                break;
            case "plain":
                // default works
                // otherwise, "1 0" can be used
                break;
            }
            if (dashStyle != null) {
                jg.writeStringField("dashstyle", dashStyle);
            }
        }
        jg.writeEndObject();

        jg.writeFieldName("hoverPaintStyle");
        jg.writeStartObject();
        jg.writeFieldName("strokeStyle");
        jg.writeObject(this.getHoverColor());
        jg.writeEndObject();

        // BEGIN: Overlays

        jg.writeFieldName("overlays");
        jg.writeStartArray();

        // source arrow head
        String head = this.getSourceArrowHead();
        if (!head.equals("none")) {
            jg.writeStartArray();
            jg.writeString(head);

            jg.writeStartObject();

            jg.writeFieldName("location");
            jg.writeNumber(0);

            // arrow should point towards the node and not away from it
            jg.writeFieldName("direction");
            jg.writeNumber(-1);

            jg.writeFieldName("width");
            jg.writeNumber(20);

            jg.writeFieldName("length");
            jg.writeNumber(12);

            jg.writeEndObject();
            jg.writeEndArray();
        }

        // target arrow head
        head = this.getTargetArrowHead();
        if (!head.equals("none")) {
            jg.writeStartArray();
            jg.writeString(head);
            jg.writeStartObject();
            jg.writeFieldName("location");
            jg.writeNumber(1);
            jg.writeFieldName("width");
            jg.writeNumber(20);
            jg.writeFieldName("length");
            jg.writeNumber(12);
            jg.writeEndObject();
            jg.writeEndArray();
        }

        // Type in brackets on the arrow
        jg.writeStartArray();
        jg.writeString("Label");
        jg.writeStartObject();
        jg.writeStringField("id", "label");
        //jg.writeStringField("label", "(" + ((RelationshipTypeResource) this.res).getName() + ")");
        jg.writeStringField("label", "");
        jg.writeStringField("cssClass", "relationshipTypeLabel");
        jg.writeFieldName("location");
        jg.writeNumber(0.5);
        jg.writeEndObject();
        jg.writeEndArray();

        jg.writeEndArray();

        // END: Overlays

        jg.writeEndObject();

        jg.close();
    } catch (Exception e) {
        VisualAppearanceResource.logger.error(e.getMessage(), e);
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build();
    }
    String res = sw.toString();
    return Response.ok(res).build();
}

From source file:org.apache.airavata.db.AbstractThriftSerializer.java

@Override
public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException {
    jgen.writeStartObject();//  ww w .jav a  2 s.co m
    for (final E field : getFieldValues()) {
        if (value.isSet(field)) {
            final Object fieldValue = value.getFieldValue(field);
            if (fieldValue != null) {
                log.debug("Adding field {} to the JSON string...",
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));

                jgen.writeFieldName(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                if (fieldValue instanceof Short) {
                    jgen.writeNumber((Short) fieldValue);
                } else if (fieldValue instanceof Integer) {
                    jgen.writeNumber((Integer) fieldValue);
                } else if (fieldValue instanceof Long) {
                    jgen.writeNumber((Long) fieldValue);
                } else if (fieldValue instanceof Double) {
                    jgen.writeNumber((Double) fieldValue);
                } else if (fieldValue instanceof Float) {
                    jgen.writeNumber((Float) fieldValue);
                } else if (fieldValue instanceof Boolean) {
                    jgen.writeBoolean((Boolean) fieldValue);
                } else if (fieldValue instanceof String) {
                    jgen.writeString(fieldValue.toString());
                } else if (fieldValue instanceof Collection) {
                    log.debug("Array opened for field {}.",
                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                    jgen.writeStartArray();
                    for (final Object arrayObject : (Collection<?>) fieldValue) {
                        jgen.writeObject(arrayObject);
                    }
                    jgen.writeEndArray();
                    log.debug("Array closed for field {}.",
                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
                } else {
                    jgen.writeObject(fieldValue);
                }
            } else {
                log.debug("Skipping converting field {} to JSON:  value is null!",
                        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
            }
        } else {
            log.debug("Skipping converting field {} to JSON:  field has not been set!",
                    CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, field.getFieldName()));
        }
    }
    jgen.writeEndObject();
}

From source file:com.buaa.cfs.conf.Configuration.java

/**
 * Writes out all the parameters and their properties (final and resource) to the given {@link Writer} The format of
 * the output would be { "properties" : [ {key1,value1,key1.isFinal,key1.resource}, {key2,value2,
 * key2.isFinal,key2.resource}... ] } It does not output the parameters of the configuration object which is loaded
 * from an input stream.//from   w  w w  .ja  va2 s  .c  o  m
 *
 * @param out the Writer to write to
 *
 * @throws IOException
 */
public static void dumpConfiguration(Configuration config, Writer out) throws IOException {
    JsonFactory dumpFactory = new JsonFactory();
    JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
    dumpGenerator.writeStartObject();
    dumpGenerator.writeFieldName("properties");
    dumpGenerator.writeStartArray();
    dumpGenerator.flush();
    synchronized (config) {
        for (Entry<Object, Object> item : config.getProps().entrySet()) {
            dumpGenerator.writeStartObject();
            dumpGenerator.writeStringField("key", (String) item.getKey());
            dumpGenerator.writeStringField("value", config.get((String) item.getKey()));
            dumpGenerator.writeBooleanField("isFinal", config.finalParameters.contains(item.getKey()));
            String[] resources = config.updatingResource.get(item.getKey());
            String resource = UNKNOWN_RESOURCE;
            if (resources != null && resources.length > 0) {
                resource = resources[0];
            }
            dumpGenerator.writeStringField("resource", resource);
            dumpGenerator.writeEndObject();
        }
    }
    dumpGenerator.writeEndArray();
    dumpGenerator.writeEndObject();
    dumpGenerator.flush();
}

From source file:com.bazaarvoice.jsonpps.PrettyPrintJson.java

private void copyCurrentStructure(JsonParser parser, ObjectMapper mapper, int depth, JsonGenerator generator)
        throws IOException {
    // Avoid using the mapper to parse the entire input until we absolutely must.  This allows pretty
    // printing huge top-level arrays (that wouldn't fit in memory) containing smaller objects (that
    // individually do fit in memory) where the objects are printed with sorted keys.
    JsonToken t = parser.getCurrentToken();
    if (t == null) {
        generator.copyCurrentStructure(parser); // Will report the error of a null token.
        return;//w  ww.ja  v  a  2 s. co m
    }
    int id = t.id();
    if (id == ID_FIELD_NAME) {
        if (depth > flatten) {
            generator.writeFieldName(parser.getCurrentName());
        }
        t = parser.nextToken();
        id = t.id();
    }
    switch (id) {
    case ID_START_OBJECT:
        if (sortKeys && depth >= flatten) {
            // Load the entire object in memory so we can sort its keys and serialize it back out.
            mapper.writeValue(generator, parser.readValueAs(Map.class));
        } else {
            // Don't load the whole object into memory.  Copy it in a memory-efficient streaming fashion.
            if (depth >= flatten) {
                generator.writeStartObject();
            }
            while (parser.nextToken() != JsonToken.END_OBJECT) {
                copyCurrentStructure(parser, mapper, depth + 1, generator);
            }
            if (depth >= flatten) {
                generator.writeEndObject();
            }
        }
        break;
    case ID_START_ARRAY:
        // Don't load the whole array into memory.  Copy it in a memory-efficient streaming fashion.
        if (depth >= flatten) {
            generator.writeStartArray();
        }
        while (parser.nextToken() != JsonToken.END_ARRAY) {
            copyCurrentStructure(parser, mapper, depth + 1, generator);
        }
        if (depth >= flatten) {
            generator.writeEndArray();
        }
        break;
    default:
        generator.copyCurrentEvent(parser);
        break;
    }
}

From source file:org.apache.olingo.server.core.serializer.json.ODataJsonSerializer.java

protected void writeProperty(final ServiceMetadata metadata, final EdmProperty edmProperty,
        final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json,
        Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
        throws IOException, SerializerException {
    boolean isStreamProperty = isStreamProperty(edmProperty);
    writePropertyType(edmProperty, json);
    if (!isStreamProperty) {
        json.writeFieldName(edmProperty.getName());
    }/*  ww  w .  j  a v  a 2 s . co m*/
    if (property == null || property.isNull()) {
        if (edmProperty.isNullable() == Boolean.FALSE && !isStreamProperty) {
            throw new SerializerException("Non-nullable property not present!",
                    SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
        } else {
            if (!isStreamProperty) {
                if (edmProperty.isCollection()) {
                    json.writeStartArray();
                    json.writeEndArray();
                } else {
                    json.writeNull();
                }
            }
        }
    } else {
        writePropertyValue(metadata, edmProperty, property, selectedPaths, json, expandedPaths, linked, expand);
    }
}

From source file:org.apache.olingo.server.core.serializer.json.ODataJsonSerializer.java

protected void writeExpandedNavigationProperty(final ServiceMetadata metadata,
        final EdmNavigationProperty property, final Link navigationLink, final ExpandOption innerExpand,
        Integer toDepth, final SelectOption innerSelect, final CountOption innerCount,
        final boolean writeOnlyCount, final boolean writeOnlyRef, final Set<String> ancestors, String name,
        final JsonGenerator json) throws IOException, SerializerException, DecoderException {

    if (property.isCollection()) {
        if (writeOnlyCount) {
            if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
                writeInlineCount(property.getName(), 0, json);
            } else {
                writeInlineCount(property.getName(), navigationLink.getInlineEntitySet().getCount(), json);
            }//  w  ww  . jav a  2  s .  c o  m
        } else {
            if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
                if (innerCount != null && innerCount.getValue()) {
                    writeInlineCount(property.getName(), 0, json);
                }
                json.writeFieldName(property.getName());
                json.writeStartArray();
                json.writeEndArray();
            } else {
                if (innerCount != null && innerCount.getValue()) {
                    writeInlineCount(property.getName(), navigationLink.getInlineEntitySet().getCount(), json);
                }
                json.writeFieldName(property.getName());
                writeEntitySet(metadata, property.getType(), navigationLink.getInlineEntitySet(), innerExpand,
                        toDepth, innerSelect, writeOnlyRef, ancestors, name, json);
            }
        }
    } else {
        json.writeFieldName(property.getName());
        if (navigationLink == null || navigationLink.getInlineEntity() == null) {
            json.writeNull();
        } else {
            writeEntity(metadata, property.getType(), navigationLink.getInlineEntity(), null, innerExpand,
                    toDepth, innerSelect, writeOnlyRef, ancestors, name, json);
        }
    }
}

From source file:org.apache.olingo.server.core.serializer.json.ODataJsonSerializer.java

/** Writes a geospatial value following the GeoJSON specification defined in RFC 7946. */
protected void writeGeoValue(final String name, final EdmPrimitiveType type, final Geospatial geoValue,
        final Boolean isNullable, JsonGenerator json, SRID parentSrid)
        throws EdmPrimitiveTypeException, IOException, SerializerException {
    if (geoValue == null) {
        if (isNullable == null || isNullable) {
            json.writeNull();//from   w ww .ja v a  2  s  .c om
        } else {
            throw new EdmPrimitiveTypeException("The literal 'null' is not allowed.");
        }
    } else {
        if (!type.getDefaultType().isAssignableFrom(geoValue.getClass())) {
            throw new EdmPrimitiveTypeException("The value type " + geoValue.getClass() + " is not supported.");
        }
        json.writeStartObject();
        json.writeStringField(Constants.ATTR_TYPE, geoValueTypeToJsonName.get(geoValue.getGeoType()));
        json.writeFieldName(
                geoValue.getGeoType() == Geospatial.Type.GEOSPATIALCOLLECTION ? Constants.JSON_GEOMETRIES
                        : Constants.JSON_COORDINATES);
        json.writeStartArray();
        switch (geoValue.getGeoType()) {
        case POINT:
            writeGeoPoint(json, (Point) geoValue);
            break;
        case MULTIPOINT:
            writeGeoPoints(json, (MultiPoint) geoValue);
            break;
        case LINESTRING:
            writeGeoPoints(json, (LineString) geoValue);
            break;
        case MULTILINESTRING:
            for (final LineString lineString : (MultiLineString) geoValue) {
                json.writeStartArray();
                writeGeoPoints(json, lineString);
                json.writeEndArray();
            }
            break;
        case POLYGON:
            writeGeoPolygon(json, (Polygon) geoValue);
            break;
        case MULTIPOLYGON:
            for (final Polygon polygon : (MultiPolygon) geoValue) {
                json.writeStartArray();
                writeGeoPolygon(json, polygon);
                json.writeEndArray();
            }
            break;
        case GEOSPATIALCOLLECTION:
            for (final Geospatial element : (GeospatialCollection) geoValue) {
                writeGeoValue(name, EdmPrimitiveTypeFactory.getInstance(element.getEdmPrimitiveTypeKind()),
                        element, isNullable, json, geoValue.getSrid());
            }
            break;
        }
        json.writeEndArray();

        if (geoValue.getSrid() != null && geoValue.getSrid().isNotDefault()
                && (parentSrid == null || !parentSrid.equals(geoValue.getSrid()))) {
            srid(json, geoValue.getSrid());
        }
        json.writeEndObject();
    }
}