Avalados por :
Olá a todos,
Tentei converter um XML em JSON usando o seguinte script Groovy.
```import groovy.xml.*
import groovy.json.JsonBuilder
def trial = new XmlParser()
def test = trial.parseText('''
<catalogoue>
<book>
<title>Groovy</title>
<author>Ken Barclay</author>
<publisher>Elsevier</publisher>
<isbn number='1111111111' />
</book>
<book>
<title>Object Oriented Design</title>
<author>John Savage</author>
<publisher>Elsevier</publisher>
<isbn number='2222222222' />
</book>
<book>
<title>C Programming</title>
<author>Ken Barclay</author>
<publisher>Prentice Hall</publisher>
<isbn number='3333333333' />
</book>
</catalogoue>
''')
def data = [doc:"${test.book.collect{book->
[
dox:[
name: book.title.text()
]
]
}}"]
/*def d1 = [doc:"${data}"]*/
def builder = new JsonBuilder(data)
println builder.toPrettyString()```
contacto@primeinstitute.com
(+51) 1641 9379
(+57) 1489 6964
© 2024 Copyright. Todos los derechos reservados.
Desarrollado por Prime Institute