title: How to Convert an Array of SwiftyJSON objects to a SwiftyJSON object?
body: <p>I have :-</p>
  
  <pre><code>var myArray:Array = array&lt;JSON&gt;
  </code></pre>
  
  <p>I want :- </p>
  
  <pre><code>var myJSON:JSON = myArray as? JSON
  </code></pre>
  
  <p>but i get a warning:-
  <strong>Cast from 'Array' to unrelated type 'JSON' always fails</strong></p>
  
  <p>Can anyone help me how to convert an Array object to a JSON object? </p>
  
  <p>A little more insight what i am trying to do:-
  (This might not be needed to answer my above question but still...) Note:- I am using objectMapper for mapping swiftyJSONObjects.</p>
  
  <pre><code>var monthArray = Array&lt;JSON&gt;
  var allEventsInDayArray:Array&lt;JSON&gt; = [] // an empty array
          for (_,dayObj) in monthArray
          {
              guard let dayEventsArray = dayObj["events"].array else { break   }
  
          allEventsInDayArray.appendContentsOf(dayEventsArray)
      }
  
      print(allEventsInDayArray)
      var allEventsJSON:JSON? = JSON(allEventsInDayArray)
      var EventModelArray:Array&lt;EventModel&gt;? = Mapper&lt;EventModel&gt;().mapArray(allEventsJSON?.object.allValues)
  </code></pre>