Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate unit from valid json #59

Closed
ptrocewicz opened this issue Apr 15, 2020 · 5 comments
Closed

Can't generate unit from valid json #59

ptrocewicz opened this issue Apr 15, 2020 · 5 comments

Comments

@ptrocewicz
Copy link

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"
}
]
}

@ahausladen
Copy link
Owner

What do you mean by "can't generate unit" ? JsonDataObjects can read that JSON string.

@ptrocewicz
Copy link
Author

It crashes on line 556 in Pkg.Json.Mapper (Delphi 10.3.3):
Lines.AddFormat(' %s: TObjectList<%s>;', [StubField.FieldName, StubArrayField.FieldClass.Name]);

@ahausladen
Copy link
Owner

ahausladen commented Apr 16, 2020

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

@ahausladen
Copy link
Owner

Could it be that you do a hard type cast "TJsonObject(obj)" somewhere but you cast to the wrong TJsonObject class.

@ptrocewicz
Copy link
Author

Sorry, my mistake, wrong github repo .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants