summaryrefslogtreecommitdiff
path: root/ddl/templates/json.java.ede
diff options
context:
space:
mode:
Diffstat (limited to 'ddl/templates/json.java.ede')
-rw-r--r--ddl/templates/json.java.ede17
1 files changed, 13 insertions, 4 deletions
diff --git a/ddl/templates/json.java.ede b/ddl/templates/json.java.ede
index d644ef6..ffa5876 100644
--- a/ddl/templates/json.java.ede
+++ b/ddl/templates/json.java.ede
@@ -83,16 +83,25 @@ public class JSON {
83 } 83 }
84 {% when "Maybe" %} 84 {% when "Maybe" %}
85 case {{ t.value | typeEnum }}: { 85 case {{ t.value | typeEnum }}: {
86 JSONObject obj = (JSONObject)rawObj;
87 {{ t.value | javaType }} m = new {{ t.value | javaType }} (); 86 {{ t.value | javaType }} m = new {{ t.value | javaType }} ();
88 if (obj == null || obj == JSONObject.NULL) { 87 if (rawObj == null || rawObj == JSONObject.NULL) {
89 m.valid = false; 88 m.valid = false;
90 } else { 89 } else {
91 m.valid = true; 90 m.valid = true;
92 m.data = ({{ t.value.type_ | javaType }})fromJSON (Type.{{ t.value.type_ | typeEnum }},obj); 91 m.data = ({{ t.value.type_ | javaType }})fromJSON (Type.{{ t.value.type_ | typeEnum }},(JSONObject)rawObj);
93 } 92 }
94 return m; 93 return m;
95 } 94 }
95 {% when "Int" %}
96 case {{ t.value | typeEnum }}: return ((Number)rawObj).intValue();
97 {% when "Int32" %}
98 case {{ t.value | typeEnum }}: return ((Number)rawObj).intValue();
99 {% when "Word" %}
100 case {{ t.value | typeEnum }}: return ((Number)rawObj).intValue();
101 {% when "Word32" %}
102 case {{ t.value | typeEnum }}: return ((Number)rawObj).intValue();
103 {% when "Float" %}
104 case Float: return ((Number)rawObj).floatValue();
96 {% else %} 105 {% else %}
97 case {{ t.value | typeEnum }}: return ({{ t.value | javaType }})rawObj; 106 case {{ t.value | typeEnum }}: return ({{ t.value | javaType }})rawObj;
98 {% endcase %} 107 {% endcase %}
@@ -149,7 +158,7 @@ public class JSON {
149 } 158 }
150 {% endfor %} 159 {% endfor %}
151 160
152 {% for t in usedJavaTypes %} 161 {% for t in usedTypes %}
153 {% case t.value.tag %} 162 {% case t.value.tag %}
154 {% when "Data" %} 163 {% when "Data" %}
155 {% when "V2" %} 164 {% when "V2" %}