Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2500

org.bson.json.JsonParseException: JSON reader was expecting a value but found '}'.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: 3.5.0
    • Component/s: JSON
    • None

      The following code works prior to version 3.4. but does not in 3.5.0-Snapshot

          @Test
          public void testDecode() {
              StringWriter stringWriter = new StringWriter();
              JsonWriter writer = new JsonWriter(stringWriter, new JsonWriterSettings(true));
              CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry());
              Codec<Document> documentCodec = codecRegistry.get(Document.class);
      
              Document document = new Document("dateList", Arrays.asList(new Date(), new Date()));
              documentCodec.encode(writer, document, EncoderContext.builder().build());
      
              Document decoded = documentCodec.decode(new JsonReader(stringWriter.toString()), DecoderContext.builder().build());
          }
      

      While decoding, it throws an exception after the first date is read.

      org.bson.json.JsonParseException: JSON reader was expecting a value but found '}'.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            michael.weber@bild.de Michael Weber
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: