Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8080096

Parsing a JSON object with numeric keys fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8u60
    • 8u40
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When calling JSON.parse() on a string containing an object with keys that are numbers (as strings), it will fail with

      java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 12



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      jjs -scripting
      jjs> var f = readFully("test.json");
      jjs> JSON.parse(f);
      java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 12

      Test file contents:
      {"1":7,"3":2,"5":4,"7":3,"11":11,"12":1,"13":3,"14":1,"17":4,"21":1,"31":2,"51":3,"80":6,"81":15,"91":5,"771":1,"1117":1,"1391":1,"1781":1,"11181":1,"BETTS":67,"BIRCH":226,"BIRCTI":1,"BISHOP":256}



      REPRODUCIBILITY :
      This bug can be reproduced always.

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: