Diagnostic and cause
СсылкаType is not JSON decodable
- Семейство
- topaz
- Этап
- check
- Код
TPZ5534
Причина и условия
json.parseAs requires an explicit JSON-decodable result type. Calling json.parseAs("1") without a type argument is rejected with TPZ5534; json. is accepted.
Действия
Supply the target type after json.parseAs, such as json.. Choose a JSON-decodable type for the result.
Compiler phase: check.
Compiler explanation: A typed JSON decode target is not a supported concrete Topaz data shape.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩requires an explicit type argument, e.g.⟨value⟩<User>(.Source. . ) ⟨value⟩is not JSON-decodable, so⟨value⟩cannot decode into it Source
json.parseAs requires an explicit decodable result type. A call without type arguments is rejected with TPZ5534 even when its text contains a valid JSON integer.
Typed JSON decoding needs a type argument
json.parseAs requires an explicit JSON-decodable result type. Calling json.parseAs("1") without a type argument is rejected with TPZ5534; json. is accepted.
Response
СсылкаSupply the target type after json.parseAs, such as json.. Choose a JSON-decodable type for the result.
Reproduction and verification
СсылкаRejected program
Ссылкаimport std.jsonlet decoded = json.parseAs("1")
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5534 at
example.tpz:2:15
A bare call without type arguments can also report TPZ5020 for missing contextual type. The diagnostic assertion requires TPZ5534 and permits that accompanying diagnostic.
Repaired program
Ссылкаimport std.jsonlet decoded = json.parseAs<int>("1")
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.
A bare call without type arguments can also report TPZ5020 for missing contextual type. The diagnostic assertion requires TPZ5534 and permits that accompanying diagnostic.