presto-main/src/main/java/io/prestosql/operator/scalar/JsonFunctions.java/JsonFunctions/isJsonScalar
class JsonFunctions:    @ScalarFunction
    @SqlType(StandardTypes.BOOLEAN)
    public static boolean isJsonScalar(@SqlType(StandardTypes.JSON) Slice json)
    {
        try (JsonParser parser = createJsonParser(JSON_FACTORY, json)) {
            JsonToken nextToken = parser.nextToken();
            if (nextToken == null) {
                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid JSON value: " + truncateIfNecessaryForErrorMessage(json));
            }

            if (nextToken == START_ARRAY || nextToken == START_OBJECT) {
                parser.skipChildren();
                if (parser.nextToken() != null) {
                    // extra trailing token after json array/object
                    throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid JSON value: " + truncateIfNecessaryForErrorMessage(json));
                }
                return false;
            }

            if (parser.nextToken() != null) {
                // extra trailing token after json scalar
                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid JSON value: " + truncateIfNecessaryForErrorMessage(json));
            }
            return true;
        }
        catch (IOException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid JSON value: " + truncateIfNecessaryForErrorMessage(json));
        }
    }