> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structupdate.md).

# StructUpdate

Updates or sets a key/value pair in to a struct

## Method Signature

```
StructUpdate(struct=[modifiableStruct], key=[any], value=[any])
```

### Arguments

| Argument | Type               | Required | Description                               | Default |
| -------- | ------------------ | -------- | ----------------------------------------- | ------- |
| `struct` | `modifiableStruct` | `true`   | The target struct                         |         |
| `key`    | `any`              | `true`   | The struct key                            |         |
| `value`  | `any`              | `true`   | The value to assign for the specified key |         |

## Examples

### Updates a structure value at specific key

Change value of structure item

[Run Example](https://try.boxlang.io/?code=eJzLrQwuKSpNLlGwVahW4OJ0VLBSMNTh4nQC0kZA2hlIGwNpFyBtwlVrzVUMVh1akJJYkqqhkAvVraOglKyko2BoqqBpzVVelFmS6lKaW6Ch4BXs7xecWpSZmJNZhaRcQROkDgDFciI%2F)

```java
myStruct = { 
	A : 1,
	B : 2,
	C : 3,
	D : 4
};
structUpdate( myStruct, "c", 15 );
writeDump( JSONSerialize( myStruct ) );

```

Result: {"A":1,"B":2,"C":15,"D":4}

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxljk0LgjAcxs%2FuUzz8TwaC98KDGESnAovOSweOdJO15SH67unUyDo%2Bbz8ermTD6zsSPMGC7HDBGtRoTRELjvvdoLRUt0Fm6cmHQnfEXhsWx8gr3aFwxghlwUcU27qmDVHzq6gTypYhRXhwk0wKK085tyW3AgW3kOqDya1xhR2zcHYjUF%2FrKdT2YJoA%2FsbM7KSt4Pys%2FGUurqXfg6E4jf4%2FvgHMuF3T)

```java
animals = { 
	COW : "moo",
	PIG : "oink",
	CAT : "meow"
};
// Show current animals
Dump( label="Current animals", var=animals );
// Update cat in animals
StructUpdate( animals, "cat", "purr" );
// Show animals with updated cat in animals
Dump( label="Animals with cat updated", var=animals );

```

## 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)
* [StructFindValue](/boxlang-language/reference/built-in-functions/struct/structfindvalue.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)
* [StructValueArray](/boxlang-language/reference/built-in-functions/struct/structvaluearray.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/structupdate.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.
