Stephen Olander-Waters created GROOVY-7532:
----------------------------------------------

             Summary: Make JsonParserLax(boolean useValues) available to 
interface
                 Key: GROOVY-7532
                 URL: https://issues.apache.org/jira/browse/GROOVY-7532
             Project: Groovy
          Issue Type: New Feature
          Components: JSON
    Affects Versions: 2.4.4, 2.4.3
         Environment: Linux
OpenJDK 7
            Reporter: Stephen Olander-Waters
            Assignee: Guillaume Laforge
            Priority: Minor


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.

{code}
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
// whereas supporting useValues would work
configOpts2.newField = configOpts2.newField ?: 25
{code}

Example config file:
{code}
{
  "clientId": "abc1234"
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to