如何将JSON数据存储为数组 [英] How to store JSON data as an array
本文介绍了如何将JSON数据存储为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中。
我想将该网址(它是JSON数据)存储为数组。请帮帮我
我的尝试:
In the below code .
i want to store that url (It is JSON Data) as an array. please help me
What I have tried:
let ur = URL(string:"http://demo.cogzidel.com/dropinn416/mobile/search/discover?common_currency=INR&start=1")
let task = URLSession.shared.dataTask(with: ur!) { (data, response, error) in
if error != nil
{
print("Error")
}
else
{
if let contant=data
{
do
{
let dictArray = try JSONSerialization.jsonObject(with: contant, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Dictionary<String, AnyObject> ]
推荐答案
In JavaScript we can use JSON.stringify to convert an java script array into a JSON formatted string
检查这是否可以帮助你。
将JavaScript数组转换为JSON - ProjectsGeek [ ^ ]
这篇关于如何将JSON数据存储为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文