On Sep 24, 2019, at 4:29 PM, Jörg Knebel wrote:
> I tried the following (pseudo code):
>
> Create an object
> Fill the object with some stuff
>
> Create another object and filled it with stuff including a picture
>
> Put the second object into the first.
>
> JSON Stringify($MyGreatObj)
>
> Save objectText to file
>
> Opened the file in BBEdit:
> {
> "Para1": "2019-09-24",
> "Para2": 36170,
> "ActivationCode": "activationCode",
> "Embeded": {
> "SomePict": "[object Picture]",
> "someText": "TestText",
> "aRealNumber": 3.1415926535898
> }
> }
>
> ************ NOW
>
> $ObjText := Document To Text
>
> $TestObject:=JSON Parse($ObjText)
>
>
> $TestText:=$TestObject.Embeded.sometext
>
> TestPict:=$TestObject.Embeded.somePict
>
> Both variables are EMPTY!
The text variable is empty because object property names are case sensitive.
Try “someText” for the name instead of “sometext”.
Picture object properties only store a reference to the picture, hence the
“[object Picture]” property value. JSON Stringify command does not encode
picture properties, you have to do that. You can write a wrapper method for
JSON Stringify and JSON Parse to handle this situation if you need to do this
often.
Tim
Sent from my iPad
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************