PKGeorgiev / Delphi-JsonToDelphiClass

Generates Delphi Classes based on JSON string (Json To Delphi Class Generator / JSON Data Binding Tool)
MIT License
236 stars 122 forks source link

The property ... has unknown type #7

Closed mauriciolima88 closed 6 years ago

mauriciolima88 commented 6 years ago

When the file starts as:

{ "html_attributions": [], "next_page_token": ...

it shows the message: The property [html_attributions] has unknown type.

PKGeorgiev commented 6 years ago

That's right. Json2delphi class needs arrays to have at least one element to determine Array's type (it converts arrays to Array<T> where T is the type and must be known before conversion). As a workaround if you know Array element's type, just add one fake element to it, for example:

{
"html_attributions": ["fake_element"],
"next_page_token": ...
}

In this case html_attributions will be converted to Array<string>. Hope that helps.

mauriciolima88 commented 6 years ago

Alright, I'm going to make a simple stringReplace on Json, thank you very much!

2017-11-26 19:28 GMT-02:00 PKGeorgiev notifications@github.com:

That's right. Json2delphi class needs arrays with at least one element to determine Array's type (it converts arrays to Array where T is the type and must be known before conversion). As a workaround if you know Array element's type, just add one fake element to it, for example:

{ "html_attributions": ["fake_element"], "next_page_token": ... }

In this case html_attributions will be converted to Array. Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PKGeorgiev/Delphi-JsonToDelphiClass/issues/7#issuecomment-347039851, or mute the thread https://github.com/notifications/unsubscribe-auth/AgHhYxmxirWZnh5BTDxKMz2TF62Z00xxks5s6dgYgaJpZM4QeVm- .

PKGeorgiev commented 6 years ago

Glad to help you!