... and add the `writeFieldId()` method actually
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
index f474c65..0048bda 100644
--- a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
+++ b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
@@ -825,6 +825,20 @@
*/
public abstract void writeFieldName(SerializableString name) throws IOException;
+ /**
+ * Alternative to {@link #writeFieldName(String)} that may be used
+ * in cases where property key is of numeric type; either where
+ * underlying format supports such notion (some binary formats do,
+ * unlike JSON), or for convenient conversion into String presentation.
+ * Default implementation will simply convert id into <code>String</code>
+ * and call {@link #writeFieldName(String)}.
+ *
+ * @since 2.8
+ */
+ public void writeFieldId(long id) throws IOException {
+ writeFieldName(Long.toString(id));
+ }
+
/*
/**********************************************************
/* Public API, write methods, scalar arrays (2.8)
diff --git a/src/main/java/com/fasterxml/jackson/core/json/JsonWriteContext.java b/src/main/java/com/fasterxml/jackson/core/json/JsonWriteContext.java
index 1a06ca8..c350e22 100644
--- a/src/main/java/com/fasterxml/jackson/core/json/JsonWriteContext.java
+++ b/src/main/java/com/fasterxml/jackson/core/json/JsonWriteContext.java
@@ -44,7 +44,7 @@
*/
/**
- * Name of the field of which value is to be parsed; only
+ * Name of the field of which value is to be written; only
* used for OBJECT contexts
*/
protected String _currentName;
@@ -55,8 +55,8 @@
protected Object _currentValue;
/**
- * Marker used to indicate that we just received a name, and
- * now expect a value
+ * Marker used to indicate that we just wrote a name, and
+ * now expect a value to write
*/
protected boolean _gotName;
diff --git a/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java b/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
index f9c40f4..6641151 100644
--- a/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
+++ b/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
@@ -203,7 +203,7 @@
@Override
public void writeStartObject(Object forValue) throws IOException { delegate.writeStartObject(forValue); }
-
+
@Override
public void writeEndObject() throws IOException { delegate.writeEndObject(); }
@@ -218,6 +218,11 @@
}
@Override
+ public void writeFieldId(long id) throws IOException {
+ delegate.writeFieldId(id);
+ }
+
+ @Override
public void writeArray(int[] array, int offset, int length) throws IOException {
delegate.writeArray(array, offset, length);
}