Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.4.3, 2.4.4
-
None
-
None
-
Linux
OpenJDK 7
Description
Please allow converting JsonParserLax into a roughly normal Groovy map so the following code works.
This is important because JsonParserLax is the only one that allows comments in the JSON file.
import groovy.json.JsonSlurper import groovy.json.JsonParserType def jsonSlurper = new JsonSlurper() def configOpts = jsonSlurper.parse(new File("test.conf")) assert configOpts.clientId instanceof String configOpts.newField = configOpts.newField ?: 25 def jsonSlurperLAX = new JsonSlurper().setType(JsonParserType.LAX) def configOpts2 = jsonSlurperLAX.parse(new File("test.conf")) assert configOpts2.clientId instanceof String //next line throws "Not that kind of map" exception // It needs to be converted to a more normal Groovy structure. configOpts2.newField = configOpts2.newField ?: 25
Example config file:
{ "clientId": "abc1234" }
Attachments
Issue Links
- relates to
-
GROOVY-6934 JsonSlurper in 2.3 returns LazyMap which is not thread safe for multiple reads
- Closed