Test case
1 generated file · +2 −0test/inputs/json/samples/kitchen-sink.json
Mpikedefault / TopLevel.pmod+2 −0
| @@ -58,9 +58,11 @@ TopLevel TopLevel_from_JSON(mixed json) { | ||
| 58 | 58 | retval.different_things = json["differentThings"]; |
| 59 | 59 | retval.double_value = (float)json["doubleValue"]; |
| 60 | 60 | retval.int_value = json["intValue"]; |
| 61 | + foreach (json["mapValue"]; mixed _; mixed value) if (stringp(value)) error("Unexpected string"); | |
| 61 | 62 | retval.map_value = json["mapValue"]; |
| 62 | 63 | retval.name_with_spaces = json["name with spaces"]; |
| 63 | 64 | retval.null_value = json["nullValue"]; |
| 65 | + foreach (json["nullableMapValue"]; mixed _; mixed value) if (stringp(value)) error("Unexpected string"); | |
| 64 | 66 | retval.nullable_map_value = json["nullableMapValue"]; |
| 65 | 67 | retval.people = json["people"]; |
| 66 | 68 | retval.person = json["person"]; |
Test case
1 generated file · +40 −0test/inputs/schema/class-with-additional.schema
Aschema-pikedefault / TopLevel.pmod+40 −0
| @@ -0,0 +1,40 @@ | ||
| 1 | +// This source has been automatically generated by quicktype. | |
| 2 | +// ( https://github.com/quicktype/quicktype ) | |
| 3 | +// | |
| 4 | +// To use this code, simply import it into your project as a Pike module. | |
| 5 | +// To JSON-encode your object, you can pass it to `Standards.JSON.encode` | |
| 6 | +// or call `encode_json` on it. | |
| 7 | +// | |
| 8 | +// To decode a JSON string, first pass it to `Standards.JSON.decode`, | |
| 9 | +// and then pass the result to `<YourClass>_from_JSON`. | |
| 10 | +// It will return an instance of <YourClass>. | |
| 11 | +// Bear in mind that these functions have unexpected behavior, | |
| 12 | +// and will likely throw an error, if the JSON string does not | |
| 13 | +// match the expected interface, even if the JSON itself is valid. | |
| 14 | + | |
| 15 | +class TopLevel { | |
| 16 | + mapping(string:Map)|mixed map; // json: "map" | |
| 17 | + | |
| 18 | + string encode_json() { | |
| 19 | + mapping(string:mixed) json = ([ | |
| 20 | + "map" : map, | |
| 21 | + ]); | |
| 22 | + | |
| 23 | + return Standards.JSON.encode(json); | |
| 24 | + } | |
| 25 | +} | |
| 26 | + | |
| 27 | +TopLevel TopLevel_from_JSON(mixed json) { | |
| 28 | + TopLevel retval = TopLevel(); | |
| 29 | + | |
| 30 | + foreach (json["map"]; mixed _; mixed value) if (stringp(value)) error("Unexpected string"); | |
| 31 | + retval.map = json["map"]; | |
| 32 | + | |
| 33 | + return retval; | |
| 34 | +} | |
| 35 | + | |
| 36 | +typedef bool|float Map; | |
| 37 | + | |
| 38 | +Map Map_from_JSON(mixed json) { | |
| 39 | + return json; | |
| 40 | +} |
Test case
1 generated file · +1 −0test/inputs/schema/vega-lite.schema
Mschema-pikedefault / TopLevel.pmod+1 −0
| @@ -275,6 +275,7 @@ Config Config_from_JSON(mixed json) { | ||
| 275 | 275 | retval.padding = json["padding"]; |
| 276 | 276 | retval.point = json["point"]; |
| 277 | 277 | retval.projection = json["projection"]; |
| 278 | + foreach (json["range"]; mixed _; mixed value) if (stringp(value)) error("Unexpected string"); | |
| 278 | 279 | retval.range = json["range"]; |
| 279 | 280 | retval.rect = json["rect"]; |
| 280 | 281 | retval.rule = json["rule"]; |
No generated files match these filters.