Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What's a good way to find whether a hash is a subset of another hash (deep)?

8 views
Skip to first unread message

dblock

unread,
Oct 7, 2011, 11:52:04 AM10/7/11
to
Anyone has a good way to implement is_subset_of for a hash? It needs
to work for deep hashes obviously.

I basically have json data returned in two formats: short and full. I
want to make sure that the short format is an exact subset of the full
format. When they aren't an exact subset I want the fields that exist
in the first hash and don't exist in the second.

Thanks,
-dB.

Robert Klemme

unread,
Oct 7, 2011, 6:07:14 PM10/7/11
to
On 10/07/2011 05:52 PM, dblock wrote:
> Anyone has a good way to implement is_subset_of for a hash? It needs
> to work for deep hashes obviously.

Why is that obvious? At least for me it isn't.

> I basically have json data returned in two formats: short and full. I
> want to make sure that the short format is an exact subset of the full
> format. When they aren't an exact subset I want the fields that exist
> in the first hash and don't exist in the second.

What does "short" and "full" exactly mean?

Kind regards

robert

Simon Krahnke

unread,
Oct 9, 2011, 4:37:45 PM10/9/11
to
* Robert Klemme <short...@googlemail.com> (2011-10-08) schrieb:

>On 10/07/2011 05:52 PM, dblock wrote:
>> Anyone has a good way to implement is_subset_of for a hash? It needs
>> to work for deep hashes obviously.
>
> Why is that obvious? At least for me it isn't.

Maybe that will become clear, once we learn what a deep hash is. Is that
one that Hashes as values? Or, beware, Hashes as keys? Or, something
completely different?

>> I basically have json data returned in two formats: short and full. I
>> want to make sure that the short format is an exact subset of the full
>> format. When they aren't an exact subset I want the fields that exist
>> in the first hash and don't exist in the second.
>
>What does "short" and "full" exactly mean?

It means that the short format is an exact subset of the full format.

What is an exact subset? In what way in a Hash a set?

mfg, simon .... l

0 new messages