code: public String asString(Object value) throws IOException, JSONObjectException
      {
          SegmentedStringWriter sw = new SegmentedStringWriter(_streamFactory._getBufferRecycler());
          try {
              _writeAndClose(value, _streamFactory.createGenerator(this, sw));
          } catch (JsonProcessingException e) {
              throw e;
          } catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
              throw JSONObjectException.fromUnexpectedIOE(e);
          }
          return sw.getAndClear();
      }
docs: /*
  ********************************************************************
  /* API: writing Simple objects as JSON
  ********************************************************************