# Safely storing the values of event fields

**URL:** <https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641>\
**Category:** Flow Go SDK\
**Tags:** flow-sdk-go\
**Created:** [November 16, 2020, 3:50am UTC](https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641 "2020-11-16T03:50:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yondercode](https://avatars.discourse-cdn.com/v4/letter/y/e9a140/32.png) [@yondercode](https://forum.flow.com/u/yondercode)\
**Post date:** [November 16, 2020, 3:50am UTC](https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641/1 "2020-11-16T03:50:13Z")

</div>

Hey I need some suggestion. I want to store Flow’s event data in my own database, I’m having a trouble figuring out how to store the event field’s values since I’m storing for any arbitrary events (not for any known events).

I’m new to Go, since the event field’s data type is `cadence.Value` and calling `ToGoValue()` would give me an `interface{}` which could be anything from simple integers to nested arrays, how could I serialize and store it so that I could safely deserialize it later?

---

<div class="post-metadata">

**Author:** ![yondercode](https://avatars.discourse-cdn.com/v4/letter/y/e9a140/32.png) [@yondercode](https://forum.flow.com/u/yondercode)\
**Post date:** [November 16, 2020, 6:48am UTC](https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641/2 "2020-11-16T06:48:54Z")

</div>

Ok I just found about this: `github.com/onflow/cadence/encoding/json`, perfect for my usage, it even works for optionals 🙂

```
bytes, err := json.Encode(eventField)
serialized = string(bytes[:])

```

---

<div class="post-metadata">

**Author:** ![bastian](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/bastian/32/183_2.png) [@bastian](https://forum.flow.com/u/bastian)\
**Post date:** [November 16, 2020, 5:11pm UTC](https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641/3 "2020-11-16T17:11:45Z")

</div>

@yondercode Yep, you can use JSON serialization to achieve that. In the future it would be nice to also have a more compact serialization format for the values.

What database are you using?

---

<div class="post-metadata">

**Author:** ![yondercode](https://avatars.discourse-cdn.com/v4/letter/y/e9a140/32.png) [@yondercode](https://forum.flow.com/u/yondercode)\
**Post date:** [November 17, 2020, 7:18am UTC](https://forum.flow.com/t/safely-storing-the-values-of-event-fields/641/4 "2020-11-17T07:18:39Z")

</div>

Alright I’ve been using `json.Encode` successfully. I’m using postgres as the database and storing event field values in `jsonb` type.

It allows easy querying for tracking FTs transfers and NFTs ownership history
