- assigned_to: nobody --> aalmiray
using windows XP.
JsonGroovyBuilder works in a groovy class but does not work in a grrovy script
Does not work:--------------
import net.sf.json.*
import net.sf.json.groovy.*
import net.sf.json.test.JSONAssert
def builder = new JsonGroovyBuilder()
def actual = builder.json {
string = "json"
integer = 1
bool = true
}
def expected = new JSONObject()
.element("string","json")
.element("integer",1)
.element("bool",true)
println actual
println expected
JSONAssert.assertEquals( expected, actual )
--- results
[:]
["string":"json", "integer":1, "bool":true]
exception
Does work:------------------
import net.sf.json.*
import net.sf.json.groovy.*
import net.sf.json.test.JSONAssert
class works {
static void main (args) {
def builder = new JsonGroovyBuilder()
def actual = builder.json {
string = "json"
integer = 1
bool = true
}
def expected = new JSONObject()
.element("string","json")
.element("integer",1)
.element("bool",true)
println actual
println expected
JSONAssert.assertEquals( expected, actual )
}
}
--- results
["string":"json", "integer":1, "bool":true]
["string":"json", "integer":1, "bool":true]