Package io.protostuff

Class JsonInput

java.lang.Object
io.protostuff.JsonInput
All Implemented Interfaces:
Input

public final class JsonInput extends Object implements Input
An input used for reading data with json format.
  • Field Details

    • parser

      public final com.fasterxml.jackson.core.JsonParser parser
      The wrapped json parser.
    • numeric

      public final boolean numeric
      If true, the field number will be used on json keys.
    • lastRepeated

      private boolean lastRepeated
    • lastName

      private String lastName
    • lastNumber

      private int lastNumber
  • Constructor Details

    • JsonInput

      public JsonInput(com.fasterxml.jackson.core.JsonParser parser)
    • JsonInput

      public JsonInput(com.fasterxml.jackson.core.JsonParser parser, boolean numeric)
  • Method Details

    • isNumeric

      public boolean isNumeric()
      Returns whether the incoming messages' field names are numeric.
    • getLastNumber

      public int getLastNumber()
      Gets the last field number read.
    • isLastRepeated

      public boolean isLastRepeated()
      Returns true if the last read field was a repeated field.
    • reset

      public JsonInput reset()
      Resets this input.
    • handleUnknownField

      public <T> void handleUnknownField(int fieldNumber, Schema<T> schema) throws IOException
      Description copied from interface: Input
      The underlying implementation should handle the unknown field.
      Specified by:
      handleUnknownField in interface Input
      Throws:
      IOException
    • readFieldNumber

      public <T> int readFieldNumber(Schema<T> schema) throws IOException
      Description copied from interface: Input
      Reads the field number of a message/object tied to the given schema.
      Specified by:
      readFieldNumber in interface Input
      Throws:
      IOException
    • readFieldNumber

      private <T> int readFieldNumber(Schema<T> schema, com.fasterxml.jackson.core.JsonParser parser) throws IOException
      Throws:
      IOException
    • readBool

      public boolean readBool() throws IOException
      Description copied from interface: Input
      Reads a boolean field value.
      Specified by:
      readBool in interface Input
      Throws:
      IOException
    • readByteArray

      public byte[] readByteArray() throws IOException
      Description copied from interface: Input
      Reads a byte array field value.
      Specified by:
      readByteArray in interface Input
      Throws:
      IOException
    • readBytes

      public ByteString readBytes() throws IOException
      Description copied from interface: Input
      Reads a ByteString field value.
      Specified by:
      readBytes in interface Input
      Throws:
      IOException
    • readBytes

      public void readBytes(ByteBuffer bb) throws IOException
      Description copied from interface: Input
      Reads a field value into a ByteBuffer.
      Specified by:
      readBytes in interface Input
      Throws:
      IOException
    • readDouble

      public double readDouble() throws IOException
      Description copied from interface: Input
      Reads a double field value.
      Specified by:
      readDouble in interface Input
      Throws:
      IOException
    • readEnum

      public int readEnum() throws IOException
      Description copied from interface: Input
      Reads an enum(its number) field value.
      Specified by:
      readEnum in interface Input
      Throws:
      IOException
    • readFixed32

      public int readFixed32() throws IOException
      Description copied from interface: Input
      Reads a fixed int(4 bytes) field value.
      Specified by:
      readFixed32 in interface Input
      Throws:
      IOException
    • readFixed64

      public long readFixed64() throws IOException
      Description copied from interface: Input
      Reads a fixed long(8 bytes) field value.
      Specified by:
      readFixed64 in interface Input
      Throws:
      IOException
    • readFloat

      public float readFloat() throws IOException
      Description copied from interface: Input
      Reads a float field value.
      Specified by:
      readFloat in interface Input
      Throws:
      IOException
    • readInt32

      public int readInt32() throws IOException
      Description copied from interface: Input
      Reads a variable int field value.
      Specified by:
      readInt32 in interface Input
      Throws:
      IOException
    • readInt64

      public long readInt64() throws IOException
      Description copied from interface: Input
      Reads a variable long field value.
      Specified by:
      readInt64 in interface Input
      Throws:
      IOException
    • readSFixed32

      public int readSFixed32() throws IOException
      Description copied from interface: Input
      Reads a signed+fixed int(4 bytes) field value.
      Specified by:
      readSFixed32 in interface Input
      Throws:
      IOException
    • readSFixed64

      public long readSFixed64() throws IOException
      Description copied from interface: Input
      Reads a signed+fixed long(8 bytes) field value.
      Specified by:
      readSFixed64 in interface Input
      Throws:
      IOException
    • readSInt32

      public int readSInt32() throws IOException
      Description copied from interface: Input
      Reads a signed int field value.
      Specified by:
      readSInt32 in interface Input
      Throws:
      IOException
    • readSInt64

      public long readSInt64() throws IOException
      Description copied from interface: Input
      Reads a signed long field value.
      Specified by:
      readSInt64 in interface Input
      Throws:
      IOException
    • readString

      public String readString() throws IOException
      Description copied from interface: Input
      Reads a String field value.
      Specified by:
      readString in interface Input
      Throws:
      IOException
    • readUInt32

      public int readUInt32() throws IOException
      Description copied from interface: Input
      Reads an unsigned int field value.
      Specified by:
      readUInt32 in interface Input
      Throws:
      IOException
    • readUInt64

      public long readUInt64() throws IOException
      Description copied from interface: Input
      Reads an unsigned long field value.
      Specified by:
      readUInt64 in interface Input
      Throws:
      IOException
    • mergeObject

      public <T> T mergeObject(T value, Schema<T> schema) throws IOException
      Description copied from interface: Input
      Merges an object(with schema) field value. The provided schema handles the deserialization for the object.
      Specified by:
      mergeObject in interface Input
      Throws:
      IOException
    • transferByteRangeTo

      public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException
      Description copied from interface: Input
      Transfer the byte range to the output. Capable of zero-copy transfer depending on the type of input.
      Specified by:
      transferByteRangeTo in interface Input
      Throws:
      IOException
    • readByteBuffer

      public ByteBuffer readByteBuffer() throws IOException
      Reads a byte array/ByteBuffer value.
      Specified by:
      readByteBuffer in interface Input
      Throws:
      IOException
    • skipField

      private void skipField(com.fasterxml.jackson.core.JsonParser parser) throws IOException
      Skip through the entire object/array field and all nested objects/arrays inside it
      Throws:
      IOException