Closed ptrocewicz closed 4 years ago
What do you mean by "can't generate unit" ? JsonDataObjects can read that JSON string.
It crashes on line 556 in Pkg.Json.Mapper (Delphi 10.3.3): Lines.AddFormat(' %s: TObjectList<%s>;', [StubField.FieldName, StubArrayField.FieldClass.Name]);
So you are not using my JsonDataObjects unit but reporting a bug in Delphi's own JSON library? Delphi's JSON library uses the same class names, so it could happen that TJsonObject is not from JsonDataObjects but from System.JSON.pas
Could it be that you do a hard type cast "TJsonObject(obj)" somewhere but you cast to the wrong TJsonObject class.
Sorry, my mistake, wrong github repo .
Sample json:
{ "promotions":[ { "id":1, "title":"Special offer", "start_at":"2014-11-01 00:00:00", "finish_at":"2014-11-05 00:00:00", "promotion_type":1, "promotion_value":5000, "promotion_on_type":1, "products":[ 1, 2 ], "promotion_on_value":[ 1, 2 ], "activate":2, "created_at":"2011-09-22 01:15:35" }, { "id":2, "title":"Winter sale", "start_at":"2014-12-01 00:00:00", "finish_at":"2014-12-30 00:00:00", "promotion_type":2, "promotion_value":25, "promotion_on_type":1, "products":[ 1, 2 ], "promotion_on_value":[ 1, 2 ], "activate":2, "created_at":"2011-09-22 01:15:35" } ] }