Error when I wanted to try to create a CBOR object from the content of a PDF file and insert it into an ingest-attachment

File IN_FILE = ResourceUtils.getFile("classpath:test.pdf");
   	int length = (int) IN_FILE.length();
   	RandomAccessFile aFile = new RandomAccessFile(IN_FILE, "r");
   	System.out.println("aFile :"+aFile);
       FileChannel inChannel = aFile.getChannel();
       MappedByteBuffer buffer = inChannel.map(FileChannel.MapMode.READ_ONLY, 0, inChannel.size());
       System.out.println("inChannel.size() :"+inChannel.size());
       buffer.load(); 
       //byte[] result = new byte[length];
       for (int i = 0; i < buffer.limit(); i++)
       {
          System.out.print((char) buffer.get());
       	//result[i] = buffer.get(i++);
       }
       
   	CBORObject object;

       
      object = CBORObject.FromObject(buffer.toString());
       json.put("smart_content", object);

I got this error when I wanted to try to create a CBOR object from the content of a PDF file and insert it into an ingest-attachment(smart_content) field via a JSONObject(json.put):

co.elastic.clients.Elasticsearch._types.ElasticsearchException: [es/index] failed: [illegal_argument_exception] Content field [smart_content] of unknown type [java.util.HashMap], must be string or byte array