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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page