Re: How to detect whethere if a JSON node exists
On Monday, 13 April 2020 at 02:20:39 UTC, Adnan wrote: Now in the above inner loop getStr(node["com"].str()) crashes in runtime if an array does not contain "com" node. I want to avoid that. How should I proceed? Try: if("com" in node) { }
Re: How to detect whethere if a JSON node exists
On Monday, 13 April 2020 at 02:22:33 UTC, Adam D. Ruppe wrote: On Monday, 13 April 2020 at 02:20:39 UTC, Adnan wrote: Now in the above inner loop getStr(node["com"].str()) crashes in runtime if an array does not contain "com" node. I want to avoid that. How should I proceed? Try: if("com" in node) { } Came back here to say that I found exactly this solution. Thanks.