D JSON (WAT?!)

Pavel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 24 08:34:23 PDT 2014


On Thursday, 24 July 2014 at 15:31:30 UTC, Daniel Gibson wrote:
> Am 24.07.2014 17:29, schrieb Pavel:
>> On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote:
>>> On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote:
>>>> string s = parsed["fail"].str;
>>>
>>> Since there is no entry "fail" in the object, it returns a 
>>> null
>>> JSON_VALUE pointer. Trying to get the string out of it is 
>>> then seen as
>>> a null pointer access and kills the program.
>>>
>>> Check for null on a key before trying to get a value out.
>>
>> Ok, added:
>>
>> writeln(parsed["fail"] == null);
>>
>> Now compiler complains:
>>
>> Error: incompatible types for ((parsed.opIndex("fail")) == 
>> (null)):
>> 'JSONValue' and 'typeof(null)'
>>
>>
>> WAT?!
>
>
> "is" instead of "==" ?

Nope, the compiler still complains.


More information about the Digitalmars-d-learn mailing list