Check out example codes for "swift convert array to json". It will help you in understanding the concepts better.

Code Example 1

func json(from object:Any) -> String? {
    guard let data = try? JSONSerialization.data(withJSONObject: object, options: []) else {
        return nil
    }
    return String(data: data, encoding: String.Encoding.utf8)
}

Learn ReactJs, React Native from akashmittal.com