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

Christof Thalhofer chrisml at deganius.de
Mon Jul 16 21:21:04 CEST 2018


Grmbl, I forgot something in CModel:

Am 16.07.2018 um 21:16 schrieb Christof Thalhofer:

> In CModel.class there are these two functions:
> 
> ----------------------------------------------------------------
> 
> ' Gambas class file

Private $NotSyms As String[] = ["GetModelAsJson", "FillModelFromJson"]

> '' 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180716/acd51f59/attachment.sig>


More information about the User mailing list