hs.json.encode can currently only encode tables - it would be nice to have this extended to support all other JSON types - booleans, numbers, strings, null.
NSJSONSerialization can write non-array/non-dictionary objects with NSJSONWritingFragmentsAllowed: https://developer.apple.com/documentation/foundation/nsjsonwritingoptions/nsjsonwritingfragmentsallowed