private boolean objectEnds(states currentState) {
    switch (currentState) {
      case OBJECT_START: // when empty object on field
      case SCALAR_FOUND:
      case LIST_ENDS:
      case OBJECT_ENDS:// inner object closes
        return true;
      default:
        throw new IllegalStateException("Object ends called when state is " + currentState);

    }
  }
Converts a PdxInstance into a JSON document in byte-array form

@param pdxInstance The PdxInstance to convert
@return the JSON byte array
@throws JSONFormatterException if unable to create the JSON document
geode-core/src/main/java/org/apache/geode/pdx/JSONFormatter.java