Steps to reproduce:
@json
export class Example {
constructor(
public a: string,
public b: string,
public c: string,
public d: string,
public e: boolean,
) {}
}
const good = `{"a":"a","b":"b","e":true,"c":"c","d":"d"}`
const good2 = `{"a":"a","b":"b","c":"c","d":"d","e":false}`
const bad = `{"a":"a","b":"b","e":false,"c":"c","d":"d"}`
const parsedGood = JSON.parse<Example>(good)
const parsedGood2 = JSON.parse<Example>(good2)
const parsedBad = JSON.parse<Example>(bad)
bad is the same as good, but with "e" toggled to false. It won't work. Either deserialization fails with Unexpected key in JSON object, or strings are deserialized as empty strings. Haven't been to understand when or why this happens.
Using [email protected]