I hope, this change does not affect the way I use (some of the) mnemonics - am I right?

Class My.Mnemonics Extends %RegisteredObject
{
/// Set-/Reset mnemonic routine
ClassMethod SetMnemonics(rou={$zname}) [ ProcedureBlock = 0 ]
{
    set old=##class(%Device).GetMnemonicRoutine()
    use $i::"^"_rou
    quit old
    
MA(x)	write "This is MA "_x quit
MB()	write "This is MB" quit
}
}


// for example:
set old=##class(My.Mnemonics).SetMnemonics()
write /ma(123)
do ##class(MyMnemonics).SetMnemonics(old)

OK, I start with 47 chars... unfortunately, I have to add 20 chars more for that (stupid) extra requirement of ignoring characters like {, [, <, etc. therefore end up with 67 chars

ClassMethod IsHalfValid(x)
{
1	s z=x,x=$replace(x,"()","") g 1:x'=z q x=""
}

ClassMethod IsFullValid(x)
{
1	s z=x,x=$replace($zstrip(x,"*e",,"()"),"()","") g 1:x'=z q x=""
}

Speed was'n asked...

In the mean time the answer is already given by Mr Maslennikov and others, but to shorten your runtime,  you could also try a "variablenless" loop, maybe this gives you some seconds more... The emphasis is on "maybe".

// if you have null-subscripts enabled
if $d(^YYY(""))!1 for i=0:1 {quit:$order(@$zr)=""} write i

// if null-subscripts are not enabled
if $d(^YYY(-9E18))!1 for i=0:1 {quit:$order(@$zr)=""} write i

// of course, you can do that on any arbitrary level too
if $d(^YYY(1,2,3,""))!1 for i=0:1 {...} write i

// the value of -9E19 ist just for explanation, use a value suitable for your needs

May I ask for the background, why do you need that node count? 

As others already wrote,

write $order(^$GLOBAL(""))

gives you the first global name accessible from a given namespace. Usually, this will be a percent-global (^%...) but if you want to get the first (or all) global, which resides in a given database, the do the same as above but with extended global access

set dir = "^^c:\databases\mydb\"  // "^^" and "the path to your CACHE/IRIS.dat file"
write $order(^$|dir|GLOBAL(""))

There are several possibilities, using WinSCP  from Windows, Linux and Samba, etc. But if "using Cache codes" (Objectscript) is a  requirement, then the simplest way is: open a TCP-(server)port on the one end and a TCP-(client)port on the other end, write and read the data, close the connections. Voila. The job is done. I do not see any problem there. OK, maybe you need to open those ports. And do not forget, USB-Sticks exists too ;-))

Yes, accepts a file too, but as the following test shows, it does not make any difference... a parsing error remains parsing error

USER>set fn="/tmp/mytest.json"

USER>open fn:"nw":1 if $test { use fn write "[0.1, .2]",! close fn write "OK" } else { write "Houston, we have..." }
OK
USER>write {}.%FromJSON(fn)

<THROW>%FromJSON+38^%Library.DynamicAbstractObject.1 *%Exception.General Parsing error 3 Line 1 Offset 7
USER 2e1>

So where is that forgiving Cache/IRIS version?

Do you have a code snippet for us? Something like

write mylist.%IsA("%ListOfDataTypes") --> 1
set item = mylist.%GetAt(2)
//
// Now the big question: what do you (want to) do with this item?
//
// do you try to lock a global: lock ^myGlobal(item) ?
// do you try to open (a possible locked) Object: set obj=##class(some.class).%OpenId(item [,4]) ?
// something else?

May I ask, which Cache or IRIS version you use?

USER>write $zv
IRIS for UNIX (Ubuntu Server LTS for x86-64) 2021.2 (Build 649U) Thu Jan 20 2022 08:49:51 EST
USER>write ##class(%DynamicAbstractObject).%FromJSON("[0.1, .2]")

<THROW>%FromJSON+38^%Library.DynamicAbstractObject.1 *%Exception.General Parsing error 3 Line 1 Offset 7
USER 2e1>

As you see, my IRIS is by far not so forgiving... ☹

I'm not aware of any $ISJSON() or similar named function but you can easily make your own

ClassMethod IsJSON(str)
{
	try { ret:{}.%FromJSON(str) 1 } catch e { ret:e.Code=3 0 throw e }
}

set a="{name:""John Doe"" "
set b="{""name"":""John Doe"" }"

write ##class(some.class).IsJSON(a) --> 0
write ##class(some.class).IsJSON(b) --> 1
write ##class(some.class).IsJSON()  --> <UNDEFINED>zIsJSON+1^...  *str

As an addition to the above possibilities, you can  ALWAYS use (assumed, you have the rights to access the database where the global lives - this is true for both of the above too) extended global access.

Just one remark, this kind of access is possible but not the recommended way for creating regular classes (databases) rather to occasionally (on demand) access data from other namespace and/or namespaces.

set nsp = "USER"
set myvar = ^|nsp|MyGlobal(1,2,3)

If there is no namespace associated with the database (where the global lives) just use the implicit namespace

set dir = "^^C:\mydatabases\myfolder\"    // win-world, "^^pathToTheDatabase"
set dir = "^^/opt/mydatabases/myfolder/"  // unix-world, 
write ^|dir|myglobal(1,2,3)

// and, of course all other commands and functions
kill ^|dir|myglobal(1)
write $order(^|dir|myglobal(1,2))
set isDef = $data(^|dir|myglobal)