E07580: must return a JSON
What went wrong
A function or method is required to return JSON type but returns something else.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 887 (Why must the $$ operator always return JSON in EK9?)
How to fix it
- Change return type to JSON
Common causes
- JSON serialization operator returning wrong type
- API response type mismatch
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07580: must return a JSON
#!ek9 defines module error.e07580.bad defines class Label text <- "label" //'$$' converts to JSON default operator ? operator $$ as pure <- rtn as String: text
Fixed: Return JSON
#!ek9 defines module error.e07580.good defines class Label text <- "label" default operator ? operator $$ as pure <- rtn as JSON: JSON("text", JSON(text))
Questions and answers
These Q&A entries show E07580 and its fix:
- Q887: Why must the $$ operator always return JSON in EK9?
- Q1255: Create me a Product record and use the SINGLE-dollar $ operator to convert it to a plain-text human-readable String.
- Q1258: Create me an Invoice class with a DOUBLE-dollar $$ operator that returns a JSON value — no plain-text formatting, only JSON.