Re: Confused array type in an object

2019-08-09 Thread John DeSoi via 4D_Tech

> OB Get Array($ObjData;$attributeName;$aTextarray) //Where $aTextarray is an 
> Array of type text
> 
> This indeed gets the values from the object..which would be absolutely 
> fine(and a work around might be to get both, as neither error, and then look 
> at whether the values in the object array are null and if they are then its 
> an array of values).
> 
> So my question is this. What is a better way to find out what the type of 
> data in the attribute is? What am I missing in my understanding of the 
> structure of an/this object.

It is the only way to do it in version 16 because all elements for the array 
must have the same type (unlike v17 collections). Once you have the text you 
can use JSON Parse to work out individual elements.

> 
> OB Get type returns 42(matching the attribute type of course!). It feels like 
> the attribute is Shrodingers Cat- existing as a collection of cats and not a 
> collection of cats at the same time. 

Be careful that 4D 16 and 17 use different constants for the same object 
property. 17 will use 42 = Is collection, whereas 16 says 39 = Object array.

John DeSoi, Ph.D.

**
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: Confused array type in an object

2019-08-09 Thread Neil Dennis via 4D_Tech

I don’t think 4D can type {additional_information:[Check / Money order]}… It 
can’t be text because it isn’t quoted, it can’t be a text array. A text array 
would be formatted like this ["Check / Money order”] so I’m not surprised that 
4D is returning null.

4D object are not JSON objects, just similar.

Neil


> On Aug 9, 2019, at 1:11 PM, Nigel Greenlee via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Hi.
> 
> I am looking for a better solution than what i currently have..this has 
> probably been encountered by others.
> 
> I am creating some code on 4D V17 but I can not really use collections or 
> .notation as this is going to get deployed on V16 and will not be upgraded 
> for at least a few months(and i am not sure that would solve this problem 
> anyway).
> 
> I am retrieving an object from a connected source(Magento FYI)... from the 
> object  we get a sub entity object and that sub entity may itself contain a 
> subentity etc etc(we are mapping data to go into our system). I am trying to 
> write something agnostic and generic so i am not expecting to ‘hard wire’ any 
> behaviour for a specific entity into the code that extracts the data.
> 
> So at each ‘entity’ level I get the attribute names and types. where the 
> attribute type is 38 or 42 this is a ‘sub entity’ so we are going to get that 
> object and call back into the same code to go down a level.
> 
> Now on V16 of course i wont get a type 42 but actually a type 42 SHOULD(as i 
> understand it) mean the object (element) contains an object and that object 
> SHOULD be a ‘complex’ object and my understanding is that should be an array 
> of objects(else it would not be a collection)? Have i misunderstood that? 
> 
> So i should be able to write(for a type 42 attribute)..
> 
> OB Get Array($ObjData;$attributeName;$aObjSubObject) //Where $aObjSubObject 
> is an Array Object
> 
> (and mostly that works)….
> 
> 
> However
> 
> I am finding a case where
> Attribute Type =42 
> Attribute Name=“additional_information"
> 
> ...and the object looks like this:-
> 
> {account_status:null,additional_information:[Check / Money 
> order],amount_ordered...
> 
> in that object ‘additional_information’ looks like
> additional_information:[Check / Money order]
> 
> which as any JSON/4D object fool can see(LOL) is an array type object(of text 
> in this case) not a collection of objects. When i retreive it as an array of 
> objects I get the correct number of elements(1) but the value of the 
> element(1) is NULL because its not [{…
> 
> 
> indeed if I write:-
> 
> 
> OB Get Array($ObjData;$attributeName;$aTextarray) //Where $aTextarray is an 
> Array of type text
> 
> This indeed gets the values from the object..which would be absolutely 
> fine(and a work around might be to get both, as neither error, and then look 
> at whether the values in the object array are null and if they are then its 
> an array of values).
> 
> So my question is this. What is a better way to find out what the type of 
> data in the attribute is? What am I missing in my understanding of the 
> structure of an/this object.
> 
> OB Get type returns 42(matching the attribute type of course!). It feels like 
> the attribute is Shrodingers Cat- existing as a collection of cats and not a 
> collection of cats at the same time. 
> 
> 
> Nigel Greenlee
> 
> 
> 
> **
> 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
> **

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

Confused array type in an object

2019-08-09 Thread Nigel Greenlee via 4D_Tech
Hi.

I am looking for a better solution than what i currently have..this has 
probably been encountered by others.

I am creating some code on 4D V17 but I can not really use collections or 
.notation as this is going to get deployed on V16 and will not be upgraded for 
at least a few months(and i am not sure that would solve this problem anyway).

I am retrieving an object from a connected source(Magento FYI)... from the 
object  we get a sub entity object and that sub entity may itself contain a 
subentity etc etc(we are mapping data to go into our system). I am trying to 
write something agnostic and generic so i am not expecting to ‘hard wire’ any 
behaviour for a specific entity into the code that extracts the data.

So at each ‘entity’ level I get the attribute names and types. where the 
attribute type is 38 or 42 this is a ‘sub entity’ so we are going to get that 
object and call back into the same code to go down a level.

 Now on V16 of course i wont get a type 42 but actually a type 42 SHOULD(as i 
understand it) mean the object (element) contains an object and that object 
SHOULD be a ‘complex’ object and my understanding is that should be an array of 
objects(else it would not be a collection)? Have i misunderstood that? 

So i should be able to write(for a type 42 attribute)..

OB Get Array($ObjData;$attributeName;$aObjSubObject) //Where $aObjSubObject is 
an Array Object

(and mostly that works)….


However

I am finding a case where
Attribute Type =42 
Attribute Name=“additional_information"

...and the object looks like this:-

{account_status:null,additional_information:[Check / Money 
order],amount_ordered...

in that object ‘additional_information’ looks like
additional_information:[Check / Money order]

which as any JSON/4D object fool can see(LOL) is an array type object(of text 
in this case) not a collection of objects. When i retreive it as an array of 
objects I get the correct number of elements(1) but the value of the element(1) 
is NULL because its not [{…


indeed if I write:-


OB Get Array($ObjData;$attributeName;$aTextarray) //Where $aTextarray is an 
Array of type text

This indeed gets the values from the object..which would be absolutely fine(and 
a work around might be to get both, as neither error, and then look at whether 
the values in the object array are null and if they are then its an array of 
values).

So my question is this. What is a better way to find out what the type of data 
in the attribute is? What am I missing in my understanding of the structure of 
an/this object.

OB Get type returns 42(matching the attribute type of course!). It feels like 
the attribute is Shrodingers Cat- existing as a collection of cats and not a 
collection of cats at the same time. 


Nigel Greenlee



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