falkreon / Jankson

JSON5 / HJSON parser and preprocessor which preserves ordering and comments
MIT License
51 stars 9 forks source link

Jankson 1.2.0-75 stiill doesn't quote keys containing ":" when requesting unquoted keys #38

Closed Barteks2x closed 4 years ago

Barteks2x commented 4 years ago

this code:

JsonObject obj = new JsonObject();
obj.put("test:key", JsonNull.INSTANCE);

System.out.println(obj.toJson(JsonGrammar.builder().printUnquotedKeys(true).build()));

outputs the following invalid json:

{
    test:key: null
}
falkreon commented 4 years ago

Regression of #26 , seems to happen becuase Pattern.compile("[a-zA-Z0-9]+").asPredicate() matches "test:key" but not ":", even though it works in regexr, so I'm going to have to reread the Pattern javadocs

Edit: I think I've got it, going with ^[a-zA-Z0-9]+$

falkreon commented 4 years ago

This also has a unit test so if it breaks in the future, I'll know