title: How to deal with empty array to be sent as json in swift?
body: <p>I'm trying to encode data but struggling to deal with empty array with no type as the API's I am working with needs me to send <strong>[]</strong> if there is no entry.</p>
  <pre><code>[
      {
          &quot;RequestId&quot;: &quot;5B6E36D9-8759-41BB-A0C0-EDFB116DFBB7&quot;,
          &quot;DataSources&quot;: [&quot;5B6E36D9-8759-41BB-A0C0-EDFB116DFBB7&quot;],
          &quot;GroupBy&quot;: [],
          &quot;Filters&quot;: []
      }
  ]
  </code></pre>
  <p>above is the object json which I have to send.</p>
  <pre><code>struct ResponseElement: Encodable {
      let requestID: String
      let dataSources: [String]
      let groupBy: []
      let filters: []
  
      enum CodingKeys: String, CodingKey {
          case requestID = &quot;RequestId&quot;
          case dataSources = &quot;DataSources&quot;
          case groupBy = &quot;GroupBy&quot;
          case filters = &quot;Filters&quot;
      }
  }
  
  let data = ResponseElement(requestID: &quot;5B6E36D9-8759-41BB-A0C0-EDFB116DFBB7&quot;,
                             dataSources: [&quot;5B6E36D9-8759-41BB-A0C0-EDFB116DFBB7&quot;, [&quot;5B6E36D9-8759-41BB-A0C0-EDFB116DFBB7]&quot;],
                             groupBy: [],
                             filters: [])
  
  let jsonEncoder = JSONEncoder()
  let data = try! jsonEncoder.encode(data)
  </code></pre>
  <p>please note while creating data variable I have to pass <strong>groupBy, filters</strong> as empty array <strong>[]</strong>, I have tried with [nil] which goes as [null] after encoding but it doesn't work in my case, it has to be <strong>[]</strong></p>
  <p>how do I solve this please?</p>