# Load json into struct in module-attribute

**URL:** <https://forum.elixirforum.com/t/load-json-into-struct-in-module-attribute/43084>\
**Category:** Questions\
**Tags:** compile, struct, defstruct\
**Created:** [October 14, 2021, 12:36pm UTC](https://forum.elixirforum.com/t/load-json-into-struct-in-module-attribute/43084 "2021-10-14T12:36:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![LostKobrakai](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/32/3072_2.png) [@LostKobrakai](https://forum.elixirforum.com/u/LostKobrakai)\
**Post date:** [October 14, 2021, 2:26pm UTC](https://forum.elixirforum.com/t/load-json-into-struct-in-module-attribute/43084/6 "2021-10-14T14:26:32Z")

</div>

> [@Sebb](#):
>
> So you can use ` __MODULE__ `, but not `% __MODULE__ {}`

The first is just a dump alias for the current module name. The second is creating a struct, which does do things like checking keys, and such, which does fail without the struct being defined.

`&Map.put(&1, : __struct__ , __MODULE__ )` just uses knowledge about implementation details of structs to construct them without doing all the consistency checks structs have when being constructed otherwise.

---

_[View the full topic](https://forum.elixirforum.com/t/load-json-into-struct-in-module-attribute/43084)._
