[Gambas-user] oibject serialization, how to do?

PICCORO McKAY Lenz mckaygerhard at gmail.com
Mon Jul 16 21:28:50 CEST 2018


2018-07-16 15:21 GMT-04:00 Christof Thalhofer <chrisml at deganius.de>:
> Grmbl, I forgot something in CModel:
yeah i was reading: "there's something here that i need?"
> Private $NotSyms As String[] = ["GetModelAsJson", "FillModelFromJson"]

GREAT EXAMPLE THANKS! good trick using json class ka ka ka


>
>> '' Creates a JSon string containing the properties and content
>> '' of the model.
>> '' Symbol names beginning with "_" are excluded.
>>
>> Public Function GetModelAsJson() As String
>>
>>     Dim symname As String
>>     Dim col As New JSONCollection
>>     Dim Value As Variant
>>
>>     For Each symname In Object.Class(Me).Symbols
>>         If Not $NotSyms.Exist(symname) Then
>>             If Left(symname, 1) <> "_" Then
>>                 Try Value = Object.GetProperty(Me, symname)
>>                 If IsNull(Value) Then
>>                     col.Add(JSON.Null, symname)
>>                 Else
>>                     col.Add(Value, symname)
>>                 Endif
>>             Endif
>>         Endif
>>     Next
>>
>>     Return JSON.Encode(col)
>
> ...
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>


More information about the User mailing list