# Cast STRUCT to ARRAY of STRUCT

**URL:** <https://forum.confluent.io/t/cast-struct-to-array-of-struct/5823>\
**Category:** ksqlDB\
**Created:** [18 August 2022 12:15 UTC](https://forum.confluent.io/t/cast-struct-to-array-of-struct/5823 "2022-08-18T12:15:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KevinBegrow](https://avatars.discourse-cdn.com/v4/letter/k/dfb087/32.png) [@KevinBegrow](https://forum.confluent.io/u/KevinBegrow)\
**Post date:** [18 August 2022 12:15 UTC](https://forum.confluent.io/t/cast-struct-to-array-of-struct/5823/1 "2022-08-18T12:15:19Z")

</div>

Hello everyone,  
I needs your help with KSQLDB.  
I get messages in a topic where the structure either comes as an STRUCT or as ARRAY with STRUCTs (SkuLine).  
I would like to change the structure i a way, that the structure is always an ARRAY with STRUCTs, even if there is just one element.  
So I would be able to define a schema on it.

Is there an option to CAST a STRUCT to an ARRAY or something similar?

ARRAY:

```auto
"saleLines": {
    "SkuLine": [{
          key:value,
          key:value
       },
      {
         key:value,
         key:value
       }],
  },...

```

STRUCT

```auto
"saleLines": {
    "SkuLine": {
        key:value,
        key:value
     }
},...

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [17 September 2022 12:16 UTC](https://forum.confluent.io/t/cast-struct-to-array-of-struct/5823/2 "2022-09-17T12:16:08Z")

</div>

Closed on 17 September 2022 12:16 UTC

This topic was automatically closed after 30 days. New replies are no longer allowed.
