Re: How to lookup a value within an object within an object

2019-10-25 Thread Tom Benedict via 4D_Tech
Thanks for the response Kirk.


> On Oct 25, 2019, at 14:45, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> OB Get works on any object so you could call
> 
> $value:=OB
> Get(myObject.data.object.billing_details.address;"postal_code";Is text)
> 
> and it will work because myObject.data.object.billing_details.address is an
> object. 

As you point out, dot notation does work as I expected it should. I just had 
the wrong syntax for OB GET.

> It's handy to break up objects like that if you are doing more than one
> thing with them. I might do something like:
> 
> $adrs_obj:=myObject.data.object.billing_details.address
> 
> so that
> 
> $value:=$adrs_obj.posta_code
> 

> And this also makes it easier to update the address object:
> 
> $adrs_obj.posta_code:="new zip code”
> 

Thanks for pointing that out. Assigning the object reference to a variable 
makes  maintenance much easier.

> Doing that also updates myObject and illustrates why objects and references
> to them are so great. You can perhaps see that having a standard object for
> all the addresses you use would allow you to write some methods for working
> with them, or verifying them, that take an address object as the parameter
> and modify the contents. Think looking up the lat/lon, correcting spelling,
> verifying, etc.
> 
> My_address_verify($adrs_obj)
> 
Thanks again.

Tom
**
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: How to lookup a value within an object within an object

2019-10-25 Thread Chip Scheide via 4D_Tech
without an additional component/plugin 

I would write a routine to extract the object, then no matter how deep 
or how your current configuration changes you can extract it.

I have only thought about this for a few moments but...
something like:
Get_object(Source_Object;Property) -> object

Get object properties with types

if the object/property desired is not at the first level
  for every object
Get_Object(ob get(Source_Object;Next_Object);Property)

else
  $0:=ob Get(Source_Object;Property)
end if


Chip
On Fri, 25 Oct 2019 13:58:10 -0700, Tom Benedict via 4D_Tech wrote:
> I’m new to objects. I have an object which holds a range of keys and 
> values. Some of the values are objects. I figured I could just use 
> the OB Get command with dot notation to reference a key in a nested 
> object, but that doesn’t seem to be supported.
> 
> Here’s my example:
> 
> C_OBJECT(myObject)
> 
> myObject :=
> "{
>   "id": "evt_1FXWZKGX5QBs0BzAQsOMqk3f",
>   "object": "event",
>   "created": 1572024442,
>   "data": {
> "object": {
>   "object": "charge",
>   "amount": 4275,
>   "billing_details": {
> "address": {
>   "city": "Burien",
>   "postal_code": "98166",
>   "state": "WA"
> },
> "name": "Willy Wonka",
>   },
>   "type": "charge.succeeded"
> }"
> 
> If I want to get the value of:
> 
> myObject.data.object.billing_details.address.postal_code 
> 
> I have to use:
> 
> OB Get(OB Get(OB Get(myObject;"data");"object");”billing_details");”
> address");”postal_code”) 
> 
> rather than:
> 
> OB Get(myObject;data.object.billing_details.address.postal_code)
> 
> I see that Cannon created a dot notation component some years ago. Is 
> that the only ‘easy’ way to do this or have I missed something?
> 
> Thanks,
> 
> Tom Benedict
> 
> **
> 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
> **
We have done so much, with so little, for so long;
We are now qualified to anything with nothing 
  - unknown
**
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: How to lookup a value within an object within an object

2019-10-25 Thread Douglas von Roeder via 4D_Tech
Tom:

Cannon’s OBJ_Module is a good enhancement to the native 4D commands.

--
Douglas von Roeder
949-910-4084


On Fri, Oct 25, 2019 at 1:58 PM Tom Benedict via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> I’m new to objects. I have an object which holds a range of keys and
> values. Some of the values are objects. I figured I could just use the OB
> Get command with dot notation to reference a key in a nested object, but
> that doesn’t seem to be supported.
>
> Here’s my example:
>
> C_OBJECT(myObject)
>
> myObject :=
> "{
>   "id": "evt_1FXWZKGX5QBs0BzAQsOMqk3f",
>   "object": "event",
>   "created": 1572024442,
>   "data": {
> "object": {
>   "object": "charge",
>   "amount": 4275,
>   "billing_details": {
> "address": {
>   "city": "Burien",
>   "postal_code": "98166",
>   "state": "WA"
> },
> "name": "Willy Wonka",
>   },
>   "type": "charge.succeeded"
> }"
>
> If I want to get the value of:
>
> myObject.data.object.billing_details.address.postal_code
>
> I have to use:
>
> OB Get(OB Get(OB
> Get(myObject;"data");"object");”billing_details");”address");”postal_code”)
>
> rather than:
>
> OB Get(myObject;data.object.billing_details.address.postal_code)
>
> I see that Cannon created a dot notation component some years ago. Is that
> the only ‘easy’ way to do this or have I missed something?
>
> Thanks,
>
> Tom Benedict
>
> **
> 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
**

How to lookup a value within an object within an object

2019-10-25 Thread Tom Benedict via 4D_Tech
I’m new to objects. I have an object which holds a range of keys and values. 
Some of the values are objects. I figured I could just use the OB Get command 
with dot notation to reference a key in a nested object, but that doesn’t seem 
to be supported.

Here’s my example:

C_OBJECT(myObject)

myObject :=
"{
  "id": "evt_1FXWZKGX5QBs0BzAQsOMqk3f",
  "object": "event",
  "created": 1572024442,
  "data": {
"object": {
  "object": "charge",
  "amount": 4275,
  "billing_details": {
"address": {
  "city": "Burien",
  "postal_code": "98166",
  "state": "WA"
},
"name": "Willy Wonka",
  },
  "type": "charge.succeeded"
}"

If I want to get the value of:

myObject.data.object.billing_details.address.postal_code 

I have to use:

OB Get(OB Get(OB 
Get(myObject;"data");"object");”billing_details");”address");”postal_code”) 

rather than:

OB Get(myObject;data.object.billing_details.address.postal_code)

I see that Cannon created a dot notation component some years ago. Is that the 
only ‘easy’ way to do this or have I missed something?

Thanks,

Tom Benedict

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