|
-
Sep 20th, 2018, 07:26 PM
#1
Thread Starter
New Member
Check if Object exists in Collection
I've created my own JSON parser in VB6. Feed it a string, it returns an Object that is a collection of the next level of Objects, each of which is a collection of the next level, etc. Normally I am accessing it with For Each x in Collection. But I need to know if a certain member exists before I bother with looping the rest of that collection. I want to test for existence with something like this:
Code:
If Not Role("Abilities")("PriorityOverride") Is Nothing Then
But that way of dereferencing is not working. Each layer is simply generic Object, not any specific object. If that isn't clear just ask and I'll try and make it clearer. Thanks!
-
Sep 20th, 2018, 08:15 PM
#2
Re: Check if Object exists in Collection
One potential trap for new players is that while Collection keys are case-insensitive this isn't true of JSON.
You could consider my JSONBag in the CodeBank or any of several other implementations that have a few miles on them to help weed out this and other problems.
But to answer your question directly... if you need an "exists" test for a Collection the most obvious route is exception handling.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|