Example #1
0
 public final void writeEndObject() throws IOException, JsonGenerationException {
   if (!_writeContext.inObject()) {
     _reportError("Current context not an object but " + _writeContext.getTypeDesc());
   }
   _writeContext = _writeContext.getParent();
   if (_cfgPrettyPrinter != null) {
     _cfgPrettyPrinter.writeEndObject(this, _writeContext.getEntryCount());
   } else {
     _writeEndObject();
   }
 }
Example #2
0
 protected JsonGeneratorBase(int features, ObjectCodec codec) {
   super();
   _features = features;
   _writeContext = JsonWriteContext.createRootContext();
   _objectCodec = codec;
   _cfgNumbersAsStrings = isEnabled(Feature.WRITE_NUMBERS_AS_STRINGS);
 }
Example #3
0
 public final void writeFieldName(String name) throws IOException, JsonGenerationException {
   // Object is a value, need to verify it's allowed
   int status = _writeContext.writeFieldName(name);
   if (status == JsonWriteContext.STATUS_EXPECT_VALUE) {
     _reportError("Can not write a field name, expecting a value");
   }
   _writeFieldName(name, (status == JsonWriteContext.STATUS_OK_AFTER_COMMA));
 }
Example #4
0
 public final void writeStartObject() throws IOException, JsonGenerationException {
   _verifyValueWrite("start an object");
   _writeContext = _writeContext.createChildObjectContext();
   if (_cfgPrettyPrinter != null) {
     _cfgPrettyPrinter.writeStartObject(this);
   } else {
     _writeStartObject();
   }
 }
Example #5
0
 public final void writeStartArray() throws IOException, JsonGenerationException {
   // Array is a value, need to verify it's allowed
   _verifyValueWrite("start an array");
   _writeContext = _writeContext.createChildArrayContext();
   if (_cfgPrettyPrinter != null) {
     _cfgPrettyPrinter.writeStartArray(this);
   } else {
     _writeStartArray();
   }
 }