# Colorize support String arg for support JSON::Serializable

**URL:** <https://forum.crystal-lang.org/t/colorize-support-string-arg-for-support-json-serializable/7407>\
**Category:** Help & Support\
**Created:** [November 13, 2024, 8:54am UTC](https://forum.crystal-lang.org/t/colorize-support-string-arg-for-support-json-serializable/7407 "2024-11-13T08:54:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [November 13, 2024, 8:54am UTC](https://forum.crystal-lang.org/t/colorize-support-string-arg-for-support-json-serializable/7407/1 "2024-11-13T08:54:11Z")

</div>

My current usage is, need passing an object from UNIXServer to UnixSocket, i define a struct for serialize/deserialize from the JSON. string.

```auto
struct ProcessStatus
      include JSON::Serializable

      getter name, log_color # ...

      def initialize(
        @name : String,
        @log_color : Symbol,
         # ...
      )
      end
    end

```

But, JSON not support symbol, i get some things error message like:

```auto
 > 128 | begin
 > 129 |
 > 130 | ::Union(Symbol).new(pull)
                                               ^--
Error: undefined method 'new' for Symbol.class

```

And, Colorize not support string as argument

```auto
 3 | puts "hello".colorize("blue")
                           ^
Error: expected argument #1 to 'String#colorize' to be (Colorize::Color256 | Colorize::ColorANSI | Colorize::ColorRGB), Symbol or UInt8, not String

```

How to workaround on this?

Thanks.

---

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [November 13, 2024, 9:05am UTC](https://forum.crystal-lang.org/t/colorize-support-string-arg-for-support-json-serializable/7407/2 "2024-11-13T09:05:44Z")

</div>

Okay, i found the solution, there is an enum [Colorize::ColorANSI](https://github.com/zw963/crystal/blob/dacd97bcc/src/colorize.cr#L209) never mentioned in the doc
