I got this to work

builder {
    HEADER {
        'FIELD' 'value'
    }
}

This one works too:

builder {
    HEADER {
        FIELD {
            'FIELD' 'value'
        }
        Field {
            field 'value'
        }
    }
}

It would appear that the methodMissing has some trouble when the missing method 
starts with capitals and gets a non closure argument. I would recommends 
opening a bug.

R.
rahul

________________________________
From: Maarten Boekhold [[email protected]]
Sent: Wednesday, October 28, 2015 1:43 AM
To: [email protected]
Subject: JsonBuilder and all-caps field names

Hi,

the following works:

def builder = new JsonBuilder()
builder {
    HEADER {
        field 'value'
    }
}

But the following gives me a compile error:

def builder = new JsonBuilder()
builder {
    HEADER {
        FIELD 'value'
    }
}

"Groovyc: unexpected token: value"

Why is that? groovy 2.4.4 btw.

Maarten



The information transmitted is intended only for the person or entity to which 
it is addressed
and may contain CONFIDENTIAL material.  If you receive this 
material/information in error,
please contact the sender and delete or destroy the material/information.

Reply via email to