On 10/ 6/17 08:02 AM, Jorgen Grahn wrote:
> On Wed, 2017-10-04, Jerry Stuckle wrote:
>> On 10/3/2017 11:48 PM, Ian Collins wrote:
>>> On 10/ 4/17 03:10 PM, Jerry Stuckle wrote:
> ....
>>>> But the real question here is - why would one need a collection of such
>>>> disparate types? I think that's where the problem lies, and also the
>>>> real answer to the problem. I think this is a case of poor design.
>>>
>>> Representing JSON objects or something similar.
>>
>> And why would that be necessary?
>
> (He didn't say it was necessary.)
>
>> JSON is a means of communicating
>> objects, i.e. between systems or in files. Every time I've used JSON
>> objects the first thing I've done in getting one is create a real object
>> out of it - and do whatever is appropriate for that object.
>
> I tend to do the same. There's already the external representation
> (JSON) and the internal one (the data structures my code does concrete
> work with); I don't want a third one, especially if it's more
> open-ended than the other two.
>
> I guess design bias like that is the reason I've never used variant/any/etc.
For the infrastructure support applications I'm frequently called upon
to write, JSON is a good internal and external format to use. These
applications tend to follow a pattern along the lines of get tree like
data from A, manipulate it and merge it with B or compare tree like data
from A and B and update one to match the other. It's easier just to use
JSON to transfer the data and manipulate it without needing to know the
types involved.
Once you have a set of algorithms (along the lines of the standard
container algorithms) to manipulate JSON objects, you can reuse them for
processing pretty much anything.
--
Ian