jparse icon indicating copy to clipboard operation
jparse copied to clipboard

Exception when ObjectNode key is empty String

Open zackhillman opened this issue 8 months ago • 0 comments

public static void main(String[] args){

    Map<String, Object> map = Json.toMap("{\"\":\"Test\"}");
    System.out.println(map);
    for (Map.Entry<String, Object> entry: map.entrySet()) {
      System.out.println(entry.getKey());
      System.out.println(entry.getValue());
    }
  }

Output:

{"":"Test"}

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
	at java.base/java.lang.String.charAt(String.java:693)
	at io.nats.jparse.source.CharArrayCharSource.matchChars(CharArrayCharSource.java:1072)
	at io.nats.jparse.node.ObjectNode.doesMatchKey(ObjectNode.java:353)
	at io.nats.jparse.node.ObjectNode.lookupElement(ObjectNode.java:323)
	at io.nats.jparse.node.ObjectNode.access$100(ObjectNode.java:30)
	at io.nats.jparse.node.ObjectNode$1$1$1.getValue(ObjectNode.java:166)
	at io.nats.jparse.node.ObjectNode$1$1$1.getValue(ObjectNode.java:158)

zackhillman avatar Jun 13 '24 18:06 zackhillman