Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · XO0437

Docs

XO0437: the string option on a non scalar field

error · reported by the checker

as "key,string" writes a scalar field as a JSON string holding its literal (5 as "5") and reads it back the same way, as Go’s json:",string" does. Go ignores the option on any other type; Xo refuses it, since a silently ignored option is a wire format bug found in production. Remove the option, or give the field a scalar type. See core 2.2 and decision 0555.

Example

struct User {
  tags as "tags,string": List[Int]
} derive Json

Fix

struct User {
  id as "id,string": Int
} derive Json

Run xo explain XO0437 for this text in a terminal, or see section 10.6 of the specification.