Test case
1 generated file · +0 −61test/inputs/schema/all-of-additional-properties-false.schema
Dschema-pikedefault / TopLevel.pmod+0 −61
| @@ -1,61 +0,0 @@ | ||
| 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 | - float amount; // json: "amount" | |
| 17 | - Frequency frequency; // json: "frequency" | |
| 18 | - mixed|string description; // json: "description" | |
| 19 | - Type type; // json: "type" | |
| 20 | - | |
| 21 | - string encode_json() { | |
| 22 | - mapping(string:mixed) json = ([ | |
| 23 | - "amount" : amount, | |
| 24 | - "frequency" : frequency, | |
| 25 | - "description" : description, | |
| 26 | - "type" : type, | |
| 27 | - ]); | |
| 28 | - | |
| 29 | - return Standards.JSON.encode(json); | |
| 30 | - } | |
| 31 | -} | |
| 32 | - | |
| 33 | -TopLevel TopLevel_from_JSON(mixed json) { | |
| 34 | - TopLevel retval = TopLevel(); | |
| 35 | - | |
| 36 | - retval.amount = json["amount"]; | |
| 37 | - retval.frequency = json["frequency"]; | |
| 38 | - retval.description = json["description"]; | |
| 39 | - retval.type = json["type"]; | |
| 40 | - | |
| 41 | - return retval; | |
| 42 | -} | |
| 43 | - | |
| 44 | -enum Frequency { | |
| 45 | - WEEKLY = "Weekly", // json: "Weekly" | |
| 46 | - MONTHLY = "Monthly", // json: "Monthly" | |
| 47 | - ANNUALLY = "Annually", // json: "Annually" | |
| 48 | -} | |
| 49 | - | |
| 50 | -Frequency Frequency_from_JSON(mixed json) { | |
| 51 | - return json; | |
| 52 | -} | |
| 53 | - | |
| 54 | -enum Type { | |
| 55 | - GROSS_SALARY_AMOUNT = "GrossSalaryAmount", // json: "GrossSalaryAmount" | |
| 56 | - OVERTIME = "Overtime", // json: "Overtime" | |
| 57 | -} | |
| 58 | - | |
| 59 | -Type Type_from_JSON(mixed json) { | |
| 60 | - return json; | |
| 61 | -} |
Test case
1 generated file · +0 −53test/inputs/schema/const-non-string.schema
Dschema-pikedefault / TopLevel.pmod+0 −53
| @@ -1,53 +0,0 @@ | ||
| 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 | - int amount; // json: "amount" | |
| 17 | - bool enabled; // json: "enabled" | |
| 18 | - Kind kind; // json: "kind" | |
| 19 | - float ratio; // json: "ratio" | |
| 20 | - float version; // json: "version" | |
| 21 | - | |
| 22 | - string encode_json() { | |
| 23 | - mapping(string:mixed) json = ([ | |
| 24 | - "amount" : amount, | |
| 25 | - "enabled" : enabled, | |
| 26 | - "kind" : kind, | |
| 27 | - "ratio" : ratio, | |
| 28 | - "version" : version, | |
| 29 | - ]); | |
| 30 | - | |
| 31 | - return Standards.JSON.encode(json); | |
| 32 | - } | |
| 33 | -} | |
| 34 | - | |
| 35 | -TopLevel TopLevel_from_JSON(mixed json) { | |
| 36 | - TopLevel retval = TopLevel(); | |
| 37 | - | |
| 38 | - retval.amount = json["amount"]; | |
| 39 | - retval.enabled = json["enabled"]; | |
| 40 | - retval.kind = json["kind"]; | |
| 41 | - retval.ratio = json["ratio"]; | |
| 42 | - retval.version = json["version"]; | |
| 43 | - | |
| 44 | - return retval; | |
| 45 | -} | |
| 46 | - | |
| 47 | -enum Kind { | |
| 48 | - WIDGET = "widget", // json: "widget" | |
| 49 | -} | |
| 50 | - | |
| 51 | -Kind Kind_from_JSON(mixed json) { | |
| 52 | - return json; | |
| 53 | -} |
Test case
1 generated file · +0 −19test/inputs/schema/issue2680-top-level-array.schema
Dschema-pikedefault / TopLevel.pmod+0 −19
| @@ -1,19 +0,0 @@ | ||
| 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 | -typedef array(int) TopLevel; | |
| 16 | - | |
| 17 | -TopLevel TopLevel_from_JSON(mixed json) { | |
| 18 | - return json; | |
| 19 | -} |
Test case
1 generated file · +0 −36test/inputs/schema/optional-any.schema
Dschema-pikedefault / TopLevel.pmod+0 −36
| @@ -1,36 +0,0 @@ | ||
| 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 | - bool bar; // json: "bar" | |
| 17 | - mixed foo; // json: "foo" | |
| 18 | - | |
| 19 | - string encode_json() { | |
| 20 | - mapping(string:mixed) json = ([ | |
| 21 | - "bar" : bar, | |
| 22 | - "foo" : foo, | |
| 23 | - ]); | |
| 24 | - | |
| 25 | - return Standards.JSON.encode(json); | |
| 26 | - } | |
| 27 | -} | |
| 28 | - | |
| 29 | -TopLevel TopLevel_from_JSON(mixed json) { | |
| 30 | - TopLevel retval = TopLevel(); | |
| 31 | - | |
| 32 | - retval.bar = json["bar"]; | |
| 33 | - retval.foo = json["foo"]; | |
| 34 | - | |
| 35 | - return retval; | |
| 36 | -} |
No generated files match these filters.