I think that I'm missing some basics on the command set and will be
grateful to anyone that can make me just that bit less foolish going
forward. For reference, all of my root objects are from

JSON Parse ("{}")

So, that's a given.

--------------------------------
 Dot Notation
--------------------------------
Nope. I knew that from the list already. I care less than many.

--------------------------------
 Count Elements
--------------------------------
Huh. How do you count things in C_OBJECTs? Like, # of instances of an
object or whatever? I've got a case where OB GET PROPERTY NAMES works
fine...but that's a special case. Am I missing something? I checked the
JSON command suite, but it's quite small and contains nothing like a count
function.

--------------------------------
 Blind Iteration
--------------------------------
Again, huh? I don't see how you can scan an object generically and explore
its contents. I did a quick-and-dirty code dump routine that takes an
object and then leans on OB GET PROPERTY NAMES to translate everything. The
type result lets you do most of what's needed. I used recursion to explore
nested objects because I didn't feel up to taking the time to writing it
properly without recursion. The real stumbling block is when you've got a
nested array. You can stash and retrieve several array types using OB
GET/SET ARRAY:

   Boolean array
   Longint array
   Object array
   Pointer array
   Real array
   Text array

OB Get type seems to report that they're object arrays, even if you stashed
something like a longint array. OB GET ARRAY doesn't want to recast them on
the fly. (I tried putting in a longint array and pulling it out as an
object array - what 4D tells me it is - and it choked.)

Am I missing something here? 4D clearly knows the underlying data type of
arrays stashed in a C_OBJECT, but I'm unclear how to get it out. I've
bashed on the JSON Stringify command and some other bits I could find, but
I don't see even an indirect way to figure out the type. I expect trying
each of the available array types with an error handler until something
works could get it done but, well, that makes me feel like I must be
missing something obvious.

Thanks for any help.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to