Fetching And Parsing Data From Json Api In Faster Way in Swift The Next CEO of Stack OverflowParse JSON in C#Parsing JSON with Unix toolsHow to parse JSON in JavaWhy can't Python parse this JSON data?Parse JSON in JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I get ASP.NET Web API to return JSON instead of XML using Chrome?How do I write JSON data to a file?How to call Objective-C code from Swift

How do I solve this limit?

How do I get the green key off the shelf in the Dobby level of Lego Harry Potter 2?

What happens if you roll doubles 3 times then land on "Go to jail?"

How to write the block matrix in LaTex?

How do spells that require an ability check vs. the caster's spell save DC work?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Customer Requests (Sometimes) Drive Me Bonkers!

Is HostGator storing my password in plaintext?

How to make a software documentation "officially" citable?

When did Lisp start using symbols for arithmetic?

How do we know the LHC results are robust?

What is the difference between "behavior" and "behaviour"?

Why is there a PLL in CPU?

Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables

If the heap is initialized for security, then why is the stack uninitialized?

Why does standard notation not preserve intervals (visually)

Does it take more energy to get to Venus or to Mars?

The King's new dress

How to write papers efficiently when English isn't my first language?

Unreliable Magic - Is it worth it?

What is the purpose of the Evocation wizard's Potent Cantrip feature?

Too much space between section and text in a twocolumn document

What materials would I use to build an underwater city?

Why do professional authors make "consistency" mistakes? And how to avoid them?



Fetching And Parsing Data From Json Api In Faster Way in Swift



The Next CEO of Stack OverflowParse JSON in C#Parsing JSON with Unix toolsHow to parse JSON in JavaWhy can't Python parse this JSON data?Parse JSON in JavaScript?How to parse JSON using Node.js?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?How do I get ASP.NET Web API to return JSON instead of XML using Chrome?How do I write JSON data to a file?How to call Objective-C code from Swift










-2















I working on a IOS project based on json API totally. I have completed my project almost but i have an issue regarding json API response rate, it is very slow and it takes time to load data in tableview. I am looking for a best way to fetch or parse data or load data in tableview quickly or faster.



here is a example of my code



 let base_url = "http://saburia.com/"
// guard let url = URL(string: "(base_url)login_verifications?phone=(textView.text ?? "")&device=ios") else return
let ID = UserDefaults.standard.string(forKey: "pos_no") ?? ""
guard let url = URL(string: "http://saburia.com/api?cat_name=1&pos_no=(ID)") else return
URLSession.shared.dataTask(with: url) (data, response, err) in
guard let data = data else return
do
//let fetchedData = try JSONDecoder().decode([uniDpt_list].self, from: data)
let myjson = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Any]


print(myjson)




var sectiontitle : [Any] = []
var catLink : [Any] = []

for game in myjson! as [AnyObject]
// print(game["name"]!!)
sectiontitle.append(game["cat_name"]!!)
catLink.append(game["cat_link"]!)
// print(dptArray)


self.CategoriesSection = sectiontitle as! [String]
self.categoryLink = catLink as! [String]

print(self.categoryLink)

DispatchQueue.main.async

self.myTableView.reloadData()


catch let jsonErr
print("Error serializing json:", jsonErr)


.resume()









share|improve this question
























  • What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

    – Aaron Brager
    Mar 8 at 12:55











  • Its takes a minute to load data mostly.

    – hussnain ahmad
    Mar 8 at 12:57












  • I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

    – Joakim Danielson
    Mar 8 at 12:58















-2















I working on a IOS project based on json API totally. I have completed my project almost but i have an issue regarding json API response rate, it is very slow and it takes time to load data in tableview. I am looking for a best way to fetch or parse data or load data in tableview quickly or faster.



here is a example of my code



 let base_url = "http://saburia.com/"
// guard let url = URL(string: "(base_url)login_verifications?phone=(textView.text ?? "")&device=ios") else return
let ID = UserDefaults.standard.string(forKey: "pos_no") ?? ""
guard let url = URL(string: "http://saburia.com/api?cat_name=1&pos_no=(ID)") else return
URLSession.shared.dataTask(with: url) (data, response, err) in
guard let data = data else return
do
//let fetchedData = try JSONDecoder().decode([uniDpt_list].self, from: data)
let myjson = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Any]


print(myjson)




var sectiontitle : [Any] = []
var catLink : [Any] = []

for game in myjson! as [AnyObject]
// print(game["name"]!!)
sectiontitle.append(game["cat_name"]!!)
catLink.append(game["cat_link"]!)
// print(dptArray)


self.CategoriesSection = sectiontitle as! [String]
self.categoryLink = catLink as! [String]

print(self.categoryLink)

DispatchQueue.main.async

self.myTableView.reloadData()


catch let jsonErr
print("Error serializing json:", jsonErr)


.resume()









share|improve this question
























  • What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

    – Aaron Brager
    Mar 8 at 12:55











  • Its takes a minute to load data mostly.

    – hussnain ahmad
    Mar 8 at 12:57












  • I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

    – Joakim Danielson
    Mar 8 at 12:58













-2












-2








-2








I working on a IOS project based on json API totally. I have completed my project almost but i have an issue regarding json API response rate, it is very slow and it takes time to load data in tableview. I am looking for a best way to fetch or parse data or load data in tableview quickly or faster.



here is a example of my code



 let base_url = "http://saburia.com/"
// guard let url = URL(string: "(base_url)login_verifications?phone=(textView.text ?? "")&device=ios") else return
let ID = UserDefaults.standard.string(forKey: "pos_no") ?? ""
guard let url = URL(string: "http://saburia.com/api?cat_name=1&pos_no=(ID)") else return
URLSession.shared.dataTask(with: url) (data, response, err) in
guard let data = data else return
do
//let fetchedData = try JSONDecoder().decode([uniDpt_list].self, from: data)
let myjson = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Any]


print(myjson)




var sectiontitle : [Any] = []
var catLink : [Any] = []

for game in myjson! as [AnyObject]
// print(game["name"]!!)
sectiontitle.append(game["cat_name"]!!)
catLink.append(game["cat_link"]!)
// print(dptArray)


self.CategoriesSection = sectiontitle as! [String]
self.categoryLink = catLink as! [String]

print(self.categoryLink)

DispatchQueue.main.async

self.myTableView.reloadData()


catch let jsonErr
print("Error serializing json:", jsonErr)


.resume()









share|improve this question
















I working on a IOS project based on json API totally. I have completed my project almost but i have an issue regarding json API response rate, it is very slow and it takes time to load data in tableview. I am looking for a best way to fetch or parse data or load data in tableview quickly or faster.



here is a example of my code



 let base_url = "http://saburia.com/"
// guard let url = URL(string: "(base_url)login_verifications?phone=(textView.text ?? "")&device=ios") else return
let ID = UserDefaults.standard.string(forKey: "pos_no") ?? ""
guard let url = URL(string: "http://saburia.com/api?cat_name=1&pos_no=(ID)") else return
URLSession.shared.dataTask(with: url) (data, response, err) in
guard let data = data else return
do
//let fetchedData = try JSONDecoder().decode([uniDpt_list].self, from: data)
let myjson = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Any]


print(myjson)




var sectiontitle : [Any] = []
var catLink : [Any] = []

for game in myjson! as [AnyObject]
// print(game["name"]!!)
sectiontitle.append(game["cat_name"]!!)
catLink.append(game["cat_link"]!)
// print(dptArray)


self.CategoriesSection = sectiontitle as! [String]
self.categoryLink = catLink as! [String]

print(self.categoryLink)

DispatchQueue.main.async

self.myTableView.reloadData()


catch let jsonErr
print("Error serializing json:", jsonErr)


.resume()






ios json swift api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 17:59









rmaddy

245k27326389




245k27326389










asked Mar 8 at 12:52









hussnain ahmadhussnain ahmad

248




248












  • What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

    – Aaron Brager
    Mar 8 at 12:55











  • Its takes a minute to load data mostly.

    – hussnain ahmad
    Mar 8 at 12:57












  • I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

    – Joakim Danielson
    Mar 8 at 12:58

















  • What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

    – Aaron Brager
    Mar 8 at 12:55











  • Its takes a minute to load data mostly.

    – hussnain ahmad
    Mar 8 at 12:57












  • I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

    – Joakim Danielson
    Mar 8 at 12:58
















What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

– Aaron Brager
Mar 8 at 12:55





What do you mean by “very slow”? You can use the time profiler instrument to see how long each line takes. But the slowness might be the network connection

– Aaron Brager
Mar 8 at 12:55













Its takes a minute to load data mostly.

– hussnain ahmad
Mar 8 at 12:57






Its takes a minute to load data mostly.

– hussnain ahmad
Mar 8 at 12:57














I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

– Joakim Danielson
Mar 8 at 12:58





I don't know if using Decodable is faster or slower but it would definitely improve your code with less casting

– Joakim Danielson
Mar 8 at 12:58












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063634%2ffetching-and-parsing-data-from-json-api-in-faster-way-in-swift%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063634%2ffetching-and-parsing-data-from-json-api-in-faster-way-in-swift%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme