Ich möchte JSON Ausgabe erzeugen ähnlich wie diese:Grails Gson JSON Ansichten
var json = {
id: "1",
name: "AAA",
children: [{
id: "2",
name: "BBB",
data: {
relation: "<b>Connections:</b><ul><li> AAA <div>(relation: direct)</div></li><li> CCC <div>(relation: direct)</div></li></ul>"
},
children: [{
id: "3",
name: "CCC",
data: {
relation: "<b>Connections:</b><ul><li> BBB <div>(relation: direct)</div></li></ul>"
},
children: []
}]
}, ....
Hier ist, was ich bisher getan:
grails create-domain-resource json.Object
class Object{
String name
String relation
static hasMany = [children: Object]
public String getData() {
def writer = new StringWriter()
_object.gson
Problem Ich bin zu produzieren nicht in der Lage:
data: {
relation: "<b>Connections:</b><ul><li> BBB <div>(relation: direct)</div></li></ul>"
},
Fragen: 1) Ich habe die offizielle Dokumentation gelesen habe, aber ich bin nicht in der Lage zu finden, wie vergänglich Felder 2) zu tun Was ist der beste Ansatz zum Mischen von JSON und XML/HTML. 3) Wie json Code zu einer anderen Ansicht Variable
danken Ihnen im Voraus
danke es funktioniert –