# StructGet

Retrieves the value from a struct using a path based expression

## Method Signature

```
StructGet(path=[string])
```

### Arguments

| Argument | Type     | Required | Description                                           | Default |
| -------- | -------- | -------- | ----------------------------------------------------- | ------- |
| `path`   | `string` | `true`   | The string path to the object requested in the struct |         |

## Examples

### Get a value in a structure using structGet

[Run Example](https://try.boxlang.io/?code=eJyrULBVqFbg4oxUsFKo5uLkjALSFlyctVy11lzlRZklqS6luQUaCsUlRaXJJe6pJRoKShV6lXpVSgqaCprWXAD06RBu)

```java
x = { 
	Y : {
		Z : 8
	}
};
writeDump( structGet( "x.y.z" ) );

```

Result: 8

### Accidentally Modifying a Structure

The structGet function will modify the variable x by adding a new structure x.a and also adds a key x.a.b to satisfy the path.

[Run Example](https://try.boxlang.io/?code=eJyrULBVqFbg4oxUsFKo5uLkjALSFlyctVy11lzlRZklqS6luQUaCsUlRaXJJe6pJRoKShV6iXpJSgqaCpooSipAfAAqMRVN)

```java
x = { 
	Y : {
		Z : 8
	}
};
writeDump( structGet( "x.a.b" ) );
writeDump( x );

```

### Accidentally Overwriting a variable using structGet

The value of x.y.z\[2] will be set to an empty struct.

[Run Example](https://try.boxlang.io/?code=eJyrULBVqFbg4oxUsFKo5uLkjALS0UCa01AHRBqBSWMgEcvFWctVa81VXpRZkupSmlugoVBcUlSaXOKeWqKhoFShV6lXFW0Uq6SgqaCJoqoCxAcAVw8YYA%3D%3D)

```java
x = { 
	Y : {
		Z : [
			1,
			2,
			3
		]
	}
};
writeDump( structGet( "x.y.z[2]" ) );
writeDump( x );

```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJyVT01rhDAUPOuvGHLaBXHvLR5EpUhLKav0nmrUgBoxz23Lsv%2B9WTdV2uKhEAgz77354L3seKsR4AzXicIcdzi7jhNGefqa5mmSWcLJnpLkxQAaJ%2BFdiWReXmB8TJ8fLWHwxTXvcu8eDsga9Q7etuA3MzeeumGHlr%2BJNmDhOmAeTnwMLMJ%2Bvn4QhIITeEHyJEkKDdkvUrWgiFO4zgJkJkFB5mwHZtd8I%2BCvAsxKz8FGoaeWNFSF32I%2Fgx7XxdWCbVmwvW3zJ%2BHNO61AjcDAqUGpDN0rgviQmjwbyXw0jb02XSG6gT6hZ9tpFL5byb6MVb1Rt1T1Vkd7%2BK9qV7mlz7ezkf8Cp3K5ig%3D%3D)

```java
animals = { 
	CAT : {
		ACTIVITIES : {
			SLEEP : true,
			EAT : true,
			DRINK : true
		}
	}
};
// Show all animals
Dump( label="All animals", var=animals );
// Get cat activities in animals
getCatActivities = StructGet( "animals.cat.activities" );
// Show results of getCatActivities
Dump( label="Results of StructGet(""animals.cat.activities"")", var=getCatActivities );
// If the path does not exist, result returns an empty structure.
findDog = StructGet( "animals.dog" );
// Show results of findDog
Dump( label="Results of StructGet(""animals.dog"")", var=findDog );

```

## Related

* [StructAppend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structappend)
* [StructClear](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structclear)
* [StructCopy](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structcopy)
* [StructDelete](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structdelete)
* [StructEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structeach)
* [StructEquals](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structequals)
* [StructEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structevery)
* [StructFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfilter)
* [StructFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfind)
* [StructFindKey](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfindkey)
* [StructFindValue](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfindvalue)
* [StructGetMetadata](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structgetmetadata)
* [StructInsert](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structinsert)
* [StructIsCaseSensitive](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structiscasesensitive)
* [StructIsOrdered](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structisordered)
* [StructKeyArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeyarray)
* [StructKeyExists](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeyexists)
* [StructKeyList](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeylist)
* [StructKeyTranslate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeytranslate)
* [StructMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structmap)
* [StructNew](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structnew)
* [StructNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structnone)
* [StructReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structreduce)
* [StructSome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structsome)
* [StructSort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structsort)
* [StructToQueryString](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structtoquerystring)
* [StructToSorted](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structtosorted)
* [StructUpdate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structupdate)
* [StructValueArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structvaluearray)
