# How to use reserved words as template field names?

**URL:** <https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118>\
**Category:** App Development\
**Created:** [March 15, 2022, 5:52pm UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118 "2022-03-15T17:52:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Broadhead](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mark_broadhead/32/3554_2.png) [@Mark\_Broadhead](https://forum.canton.network/u/Mark_Broadhead)\
**Post date:** [March 15, 2022, 5:52pm UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118/1 "2022-03-15T17:52:20Z")

</div>

I am building a workflow where the blockchain holds the state of the workflow. I have built a DAML template that is a 1:1 representation of a JSON schema I interact with, however, some of the JSON keys have names like “type” and when I try to use these words as field names, I get “parse error on input ‘type’”

How can I use the word “type” as a field name?

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [March 15, 2022, 6:35pm UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118/2 "2022-03-15T18:35:52Z")

</div>

I don’t think there is any way to do this in the language.

It would _technically_ be possible to write a [Daml-LF](https://docs.daml.com/2.0.0/app-dev/ledger-api.html#daml-lf-intro) directly that uses such a record field name. However, even in LF, field names are restricted to `[a-zA-Z_\$][a-zA-Z0-9_\$]{0,999}`, so this will not work for all possible JSON field names.

Taking into account the exceptional difficulty of writing LF directly, as well as that it is not possible to customize [the JSON representation of a given Daml type as used by JSON API](https://docs.daml.com/2.0.0/json-api/lf-value-specification.html), it would probably be simpler to assume that some translation between queried ledger values and the JSON schema you refer to will be required, sooner or later.

---

<div class="post-metadata">

**Author:** ![Leonid\_Rozenberg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/leonid_rozenberg/32/48_2.png) [@Leonid\_Rozenberg](https://forum.canton.network/u/Leonid_Rozenberg)\
**Post date:** [March 15, 2022, 7:43pm UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118/3 "2022-03-15T19:43:20Z")

</div>

@Mark_Broadhead I tend to add an underscore to that name when I want to use that name, `type_`.

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [March 16, 2022, 9:20am UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118/4 "2022-03-16T09:20:54Z")

</div>

> [@Mark\_Broadhead](#):
>
> have built a DAML template that is a 1:1 representation of a JSON schema I interact with

I’ll go a bit on a tangent here: this sounds like a bit of a smell. While we do have tooling that allows you to do this, I would recommend avoiding coupling tightly between your Daml models and the client representation of data. Daml allows you to tap in into a virtual global shared ledger, a common bus where applications can interact with data across organizational borders. I would strongly recommend you strive to make sure that your Daml models and the API exposed to clients by your Daml app can evolve independently.

---

<div class="post-metadata">

**Author:** ![Mark\_Broadhead](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/mark_broadhead/32/3554_2.png) [@Mark\_Broadhead](https://forum.canton.network/u/Mark_Broadhead)\
**Post date:** [March 23, 2022, 8:25pm UTC](https://forum.canton.network/t/how-to-use-reserved-words-as-template-field-names/4118/5 "2022-03-23T20:25:16Z")

</div>

Thanks for pointing this out. You’re right, this is a code smell. I need to refactor this model to not be tightly coupled.
