> ## Documentation Index
> Fetch the complete documentation index at: https://cantonfoundation-generated-references-ledger-bindings-update.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ValueDecoder

> A converter from the encoded form of a Daml value, represented by Value, to the codegen-decoded form, represented by Data. Every codegen class for a template, record, or variant includes a valueDecoder method that produces one of these. If the data type has type parameters, valueDecoder has arguments that correspond to ValueDecoders for those type arguments. For primitive types that are not code-generated, see PrimitiveValueDecoders. // given template 'Foo', and encoded payload 'Value fooValue' Foo foo = Foo.valueDecoder().decode(fooValue); // given Daml datatypes 'Bar a b' and 'Baz', // and encoded 'Bar' 'Value barValue' Bar<Baz, Long> bar = Bar.valueDecoder( Baz.valueDecoder(), PrimitiveValueDecoders.fromInt64) .decode(barValue); Bar<List<Baz>, Map<Long, String>> barWithAggregates = Bar.valueDecoder( PrimitiveValueDecoders.fromList(Baz.valueDecoder), PrimitiveValueDecoders.fromGenMap( PrimitiveValueDecoders.fromInt64, PrimitiveValueDecoders.fromText)) .decode(barAggregateValue); There is also a decode(Value, UnknownTrailingFieldPolicy) method that takes an additional UnknownTrailingFieldPolicy This method is used to handle unknown trailing fields in the value. Currently, the error is thrown if there are unknown trailing fields or extra fields are ignored. In the following situation if the following DAML data object is defined in the DAML project on the client side: data Bar = Bar { bar : Int, baz: Int } deriving (Eq, Show) And the following value is received from the ledger: Value(1, 2, Optional(3)) if the following code is executed on the client side, the IllegalArgumentException is thrown: Bar bar = Bar.valueDecoder().decode(value, UnknownTrailingFieldPolicy.STRICT); and if the following code is executed on the client side, the Bar object is created with bar = 1 and baz = 2, while the extra field 3 is ignored: Bar bar = Bar.valueDecoder().decode(value, UnknownTrailingFieldPolicy.IGNORE);

## ValueDecoder

Upstream docs: [Open](https://javadoc.io/doc/com.daml/bindings-java/3.5.7/com/daml/ledger/javaapi/data/codegen/ValueDecoder.html)

**Signature**

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
@FunctionalInterface public interface ValueDecoder<Data>
```

**Members**

| Docs                                                                                                                                                                                                                              | Member                                      | Introduced | Deprecated | Removed |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ---------- | ---------- | ------- |
| [Open](https://javadoc.io/doc/com.daml/bindings-java/3.5.7/com/daml/ledger/javaapi/data/codegen/ValueDecoder.html#decode%28com.daml.ledger.javaapi.data.Value%29)                                                                 | `decode(Value)`                             | `3.4.8`    | -          | -       |
| [Open](https://javadoc.io/doc/com.daml/bindings-java/3.5.7/com/daml/ledger/javaapi/data/codegen/ValueDecoder.html#decode%28com.daml.ledger.javaapi.data.Value,com.daml.ledger.javaapi.data.codegen.UnknownTrailingFieldPolicy%29) | `decode(Value, UnknownTrailingFieldPolicy)` | `3.5.7`    | -          | -       |
