If you specify ORDER BY in the SELECT statement, you must explicitly specify the field being ordered as shown in the following query:
SELECT AS JSON pkey, val FROM MyTable ORDER BY pkey ASC;
Similarly, if you specify TOP n in the SELECT statement, you must explicitly specify the field being sorted:
SELECT AS JSON TOP 2 pkey, val FROM MyTable ORDER BY pkey DESC;
The following query fails because comparisons are not allowed for the JSON type.
SELECT AS JSON a, b FROM MyTable ORDER BY 1 ASC;
The following query fails because sorting is not supported for the JSON type.
SELECT AS JSON TOP 10 a, b FROM MyTable ORDER BY 1 DESC;