Menu

#81 groovy script JsonGroovyBuilder not working

closed-fixed
aalmiray
None
5
2010-12-03
2009-03-01
No

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]

Discussion

  • aalmiray

    aalmiray - 2009-03-11
    • assigned_to: nobody --> aalmiray
     
  • aalmiray

    aalmiray - 2010-12-03
    • status: open --> closed-fixed
     

Log in to post a comment.