Assert exception in parsed JSON assignment

Issue #154 resolved
Sergio Rossi created an issue

Please try to execute the following code, which is formally correct:

 var Oggetto:=JSON.NewObject;
     Oggetto.Dati:=JSON.Parse('{"Campo":{"IDValue":5}}');
     Oggetto.SottoOggetto:=Oggetto.Dati.Campo;

The last assignment will raise an exception of an Assert within the dwJSON.pas file.

The workaround to allow the code to work is as follows:

 var Oggetto:=JSON.NewObject;
     Oggetto.Dati:=JSON.Parse('{"Campo":{"IDValue":5}}');
     Oggetto.SottoOggetto:=null;  // Workaround!
     Oggetto.SottoOggetto:=Oggetto.Dati.Campo;

As you can see, it was necessary to insert, before the last assignment, a completely useless pre assignment from a logical point of view.

In my opinion, this is a bug.

Comments (1)

  1. Log in to comment