Wrap ternary in json() to reduce repetition