Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-25 Thread Jörg Knebel via 4D_Tech


> On 25 Sep 2019, at 07:32 AEST, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:

> I would PICTURE TO BLOB and then BASE64 ENCODE the blob to create a text 
> representation of the picture. Reverse the process to bring it back. 

That sounds like a plan.

Thanks
Cheers
Jörg
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Jörg Knebel via 4D_Tech


> On 25 Sep 2019, at 04:59 AEST, Aparajita Fishman via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Property names are case-sensitive. That why this one failed.

I already figured this out.



>> So, I think 4D-Objects need more time (another 25 years?) to catch up with 
>> ObjectTools…
> 
> Usually it only takes 10-15 years for them to catch up. 

Well, that should be enough time to do a proper job - don’t you think? 浪


>> A command like OB To BLOB would be a nice point to start.
> 
> That would be pretty trivial to write yourself.

Of cause it would, but there are two obstacles in the way:

1. I’m a bloody lazy bustard
2. There is a thing available right now that works and you might be aware of 
it, it’s called “ObjectTools”. 


In conjunction with all this, I’m wondering for how long ObjectTools will be 
maintained and would there be an early warning when/if support will cease… 樂


Cheers
Jörg
   
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Kirk Brooks via 4D_Tech
Tim,

On Tue, Sep 24, 2019 at 2:32 PM Tim Nevels via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> On Sep 24, 2019, at 8:00 PM, Kirk Brooks wrote:
> > Do you have to Base64 encode the picture to store it in the JSON file?
>
> I would PICTURE TO BLOB and then BASE64 ENCODE the blob to create a text
> representation of the picture. Reverse the process to bring it back.


I suppose that would work for just about any kind of document wouldn't it?

-- 
Kirk Brooks
San Francisco, CA
===

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Tim Nevels via 4D_Tech
On Sep 24, 2019, at 8:00 PM, Kirk Brooks wrote:

> Do you have to Base64 encode the picture to store it in the JSON file?

I would PICTURE TO BLOB and then BASE64 ENCODE the blob to create a text 
representation of the picture. Reverse the process to bring it back. 

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:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Aparajita Fishman via 4D_Tech
> 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

Property names are case-sensitive. That why this one failed.


> TestPict:=$TestObject.Embeded.somePict

https://doc.4d.com/4Dv17R5/4D/17-R5/Data-Types.300-4128319.en.html 


When exposed as text in the debugger or exported to JSON, picture object 
properties print "[object Picture]”.


> So, I think 4D-Objects need more time (another 25 years?) to catch up with 
> ObjectTools…

Usually it only takes 10-15 years for them to catch up. 


> A command like OB To BLOB would be a nice point to start.

That would be pretty trivial to write yourself.

- Aparajita
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Kirk Brooks via 4D_Tech
Tim,
Do you have to Base64 encode the picture to store it in the JSON file?

On Tue, Sep 24, 2019 at 10:28 AM Tim Nevels via 4D_Tech <
4d_tech@lists.4d.com> wrote:

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


-- 
Kirk Brooks
San Francisco, CA
===

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-24 Thread Tim Nevels via 4D_Tech
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:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-23 Thread Douglas von Roeder via 4D_Tech
Auto correct…

“your code”

On Mon, Sep 23, 2019 at 6:41 PM Douglas von Roeder 
wrote:

> I haven’t tried your. Ode but dotted notation is case sensitive. Could
> that be the issue?
>
> On Mon, Sep 23, 2019 at 6:35 PM Jörg Knebel via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
>
>> G’day,
>>
>> 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!
>>
>>
>> * Next STEP
>>
>>
>> $EmbeddedObj:=$TestObject.Embeded
>>
>> $TestText:=$EmbeddedObj.sometext
>>
>>
>> $EmbeddedObj contains the object but $TestText is empty again.
>>
>> The picture is a total lost!
>>
>>
>> So, I think 4D-Objects need more time (another 25 years?) to catch up
>> with ObjectTools…
>>
>> A command like OB To BLOB would be a nice point to start.
>>
>> My 2¢
>>
>> Cheers
>> Jörg
>> **
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
>> **
>
> --
> --
> Douglas von Roeder
> 949-910-4084
>
-- 
--
Douglas von Roeder
949-910-4084
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-23 Thread Douglas von Roeder via 4D_Tech
I haven’t tried your. Ode but dotted notation is case sensitive. Could
that be the issue?

On Mon, Sep 23, 2019 at 6:35 PM Jörg Knebel via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> G’day,
>
> 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!
>
>
> * Next STEP
>
>
> $EmbeddedObj:=$TestObject.Embeded
>
> $TestText:=$EmbeddedObj.sometext
>
>
> $EmbeddedObj contains the object but $TestText is empty again.
>
> The picture is a total lost!
>
>
> So, I think 4D-Objects need more time (another 25 years?) to catch up with
> ObjectTools…
>
> A command like OB To BLOB would be a nice point to start.
>
> My 2¢
>
> Cheers
> Jörg
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

-- 
--
Douglas von Roeder
949-910-4084
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

FYI: 4D-Objects - Embedded Objects --> Save as file

2019-09-23 Thread Jörg Knebel via 4D_Tech
G’day,

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!


* Next STEP


$EmbeddedObj:=$TestObject.Embeded

$TestText:=$EmbeddedObj.sometext


$EmbeddedObj contains the object but $TestText is empty again.

The picture is a total lost!


So, I think 4D-Objects need more time (another 25 years?) to catch up with 
ObjectTools…

A command like OB To BLOB would be a nice point to start.

My 2¢

Cheers
Jörg
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**