# StructFindValue

Searches a struct for a given value and returns an array of results

## Method Signature

```
StructFindValue(struct=[structloose], value=[string], scope=[string])
```

### Arguments

| Argument | Type     | Required | Description                                                                      | Default |
| -------- | -------- | -------- | -------------------------------------------------------------------------------- | ------- |
| `struct` | `struct` | `true`   | The struct to search                                                             |         |
| `value`  | `string` | `true`   | The value to search for                                                          |         |
| `scope`  | `string` | `false`  | Either one (default), which finds the first instance or all to return all values | `one`   |

## Examples

### Find first match for a nested struct value

[Run Example](https://try.boxlang.io/?code=eJzLrQwuKSpNLlGwVahW4OJ0VLBSMNLh4nQC0iZA2hlIWwBpFyBtaABkuIIYIBVuYAZXrTVXLtQIPd%2FIYFdnfz%2BX4JCgUOcQkIlAAw2B6kxBOh2NCOkAckM8PINQ9DsZwix0Auk3M4XoD0vMKU0FqoCY45aZlwIW0VCAGa2joGRopAQk8%2FNSlRQ0rbnCizJLUv1LSwpKSzQUvIL9%2FYJTizITczKrwJog5mmCFAIA3MxIbw%3D%3D)

```java
myStruct = { 
	A : 2,
	B : 4,
	C : 8,
	D : 10,
	E : 12,
	F : 12
};
myStruct.MYSECONDSTRUCT = {
	A1 : 50,
	A2 : 12
};
myStruct.MYSECONDSTRUCT.MYTHIRDSTRUCT = {
	B1 : 12,
	B2 : 65
};
myValue = StructFindValue( myStruct, "12", "one" );
WriteOutput( JSONSerialize( myValue ) );

```

Result: \[{"path":".E","owner":{"A":2,"B":4,"C":8,"D":10,"E":12,"F":12,"MYSECONDSTRUCT":{"A1":50,"A2":12,"MYTHIRDSTRUCT":{"B2":65,"B1":12}}},"key":"E"}]

### Find all matches for a nested struct value

[Run Example](https://try.boxlang.io/?code=eJzLrQwuKSpNLlGwVahW4OJ0VLBSMNLh4nQC0iZA2hlIWwBpFyBtaABkuIIYIBVuYAZXrTVXLtQIPd%2FIYFdnfz%2BX4JCgUOcQkIlAAw2B6kxBOh2NCOkAckM8PINQ9DsZwix0Auk3M4XoD0vMKU0FqoCY45aZlwIW0VCAGa2joGRopAQkE3NylBQ0rbnCizJLUv1LSwpKSzQUvIL9%2FYJTizITczKrwJog5mmCFAIA2wdIZg%3D%3D)

```java
myStruct = { 
	A : 2,
	B : 4,
	C : 8,
	D : 10,
	E : 12,
	F : 12
};
myStruct.MYSECONDSTRUCT = {
	A1 : 50,
	A2 : 12
};
myStruct.MYSECONDSTRUCT.MYTHIRDSTRUCT = {
	B1 : 12,
	B2 : 65
};
myValue = StructFindValue( myStruct, "12", "all" );
WriteOutput( JSONSerialize( myValue ) );

```

Result: \[{"path":".E","owner":{"A":2,"B":4,"C":8,"D":10,"E":12,"F":12,"MYSECONDSTRUCT":{"A1":50,"A2":12,"MYTHIRDSTRUCT":{"B2":65,"B1":12}}},"key":"E"},{"path":".F","owner":{"A":2,"B":4,"C":8,"D":10,"E":12,"F":12,"MYSECONDSTRUCT":{"A1":50,"A2":12,"MYTHIRDSTRUCT":{"B2":65,"B1":12}}},"key":"F"},{"path":".MYSECONDSTRUCT.A2","owner":{"A1":50,"A2":12,"MYTHIRDSTRUCT":{"B2":65,"B1":12}},"key":"A2"},{"path":".MYSECONDSTRUCT.MYTHIRDSTRUCT.B1","owner":{"B2":65,"B1":12},"key":"B1"}]

### Find first match for a nested struct value using member function

CF11+ calling the findValue member function on a struct.

[Run Example](https://try.boxlang.io/?code=eJzLrQwuKSpNLlGwVahW4OJ0VLBSMNLh4nQC0iZA2hlIWwBpFyBtaABkuIIYIBVuYAZXrTVXLtQIPd%2FIYFdnfz%2BX4JCgUOcQkIlAAw2B6kxBOh2NCOkAckM8PINQ9DsZwix0Auk3M4XoD0vMKU0FqoCblJaZlwIW1FBQMjRS0lFQys9LVVLQtOYKL8osSfUvLSkoLdFQ8Ar29wtOLcpMzMmsAiqFGaQJUggA0rZF7A%3D%3D)

```java
myStruct = { 
	A : 2,
	B : 4,
	C : 8,
	D : 10,
	E : 12,
	F : 12
};
myStruct.MYSECONDSTRUCT = {
	A1 : 50,
	A2 : 12
};
myStruct.MYSECONDSTRUCT.MYTHIRDSTRUCT = {
	B1 : 12,
	B2 : 65
};
myValue = myStruct.findValue( "12", "one" );
WriteOutput( JSONSerialize( myValue ) );

```

Result: \[{"path":".E","owner":{"A":2,"B":4,"C":8,"D":10,"E":12,"F":12,"MYSECONDSTRUCT":{"A1":50,"A2":12,"MYTHIRDSTRUCT":{"B2":65,"B1":12}}},"key":"E"}]

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxljz1vwjAQhuf4V7zyEpAisbfKEFGKMrSpmqqV2NxgqIU%2FqiQuA%2BK%2F95IYUMLmOz93z3vCKiN0gxQnsGhZfOEBJxZFr0VerujNjXM8oUaZb%2Fpai3ovOYvO1HzL11PcKXsY8UZulTdhYJl93O2X7jgaaCiP7nh2fmSLBcofdwS1IIao7Mmb3xm0%2BJY65dntgyf4E3UaKsz76WdltwFA5WwrlFV2T6D2Em6HeMgXsx2BL%2F07G%2BgUZVv7qu02fHb47CJKrlcFSR%2Bxlo3XbQNlMd01jvweQLJPDTfBxcDn4ay7fKT%2BB3b7hww%3D)

```java
animals = { 
	COW : {
		NOISE : "moo",
		SIZE : "large"
	},
	PIG : {
		NOISE : "oink",
		SIZE : "medium"
	},
	CAT : {
		NOISE : "meow",
		SIZE : "small"
	}
};
// Show all animals
Dump( label="All animals", var=animals );
// Find animal containing value of 'medium'
findMediumAnimal = StructFindValue( animals, "medium" );
// Show results in findMediumAnimal
Dump( label="Results of StructFindValue(animals, ""medium"")", var=findMediumAnimal );

```

## Related

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfindvalue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
