TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tommy
NA
134
26.7k
Please, help to deserialize my JSON file on C#
Jul 11 2016 6:47 PM
<p align="left" style="font-size: 12pt;"> Hey smart people,</p><p style="font-size: 12pt;">Hope you are all well. Please, can someone help me with my C# and json code, I'll be super grateful.</p><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">Here's the content of my <strong>mydata.json</strong> file which has to be loaded from URL</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;"><pre style='color: #000000; font-family: "Courier New"; font-size: 9pt; background-color: #ffffff;'><pre style='color: #000000; font-family: "Courier New"; font-size: 9pt; background-color: #ffffff;'>global.data.retrieve(<br />{<br /><span style="color: #008000; font-weight: bold;">"Status"</span>: <span style="color: #008000; font-weight: bold;">"SUCCESS"</span>,<br /><span style="color: #008000; font-weight: bold;">"total"</span>: <span style="color: #0000ff;">3</span>,<br /><span style="color: #008000; font-weight: bold;">"results"</span>:<br />{<br /><span style="color: #008000; font-weight: bold;">"Platform"</span>: [<br />{<br /><span style="color: #008000; font-weight: bold;">"type"</span>: <span style="color: #008000; font-weight: bold;">"AA"</span>,<br /><span style="color: #008000; font-weight: bold;">"Id"</span>: <span style="color: #008000; font-weight: bold;">"420"</span>,<br /><span style="color: #008000; font-weight: bold;">"service"</span>: <span style="color: #000080; font-weight: bold;">false</span>,<br /><span style="color: #008000; font-weight: bold;">"description"</span>: <span style="color: #008000; font-weight: bold;">""</span>,<br /><span style="color: #008000; font-weight: bold;">"imageUrl"</span>: <span style="color: #008000; font-weight: bold;">"http://www.somelink.com/file.jpg"</span>,<br /><span style="color: #008000; font-weight: bold;">"date"</span>: <span style="color: #008000; font-weight: bold;">"1457608735000"<br /></span>},<br />{<br /><span style="color: #008000; font-weight: bold;">"type"</span>: <span style="color: #008000; font-weight: bold;">"BB"</span>,<br /><span style="color: #008000; font-weight: bold;">"Id"</span>: <span style="color: #008000; font-weight: bold;">"307"</span>,<br /><span style="color: #008000; font-weight: bold;">"service"</span>: <span style="color: #000080; font-weight: bold;">false</span>,<br /><span style="color: #008000; font-weight: bold;">"description"</span>: <span style="color: #008000; font-weight: bold;">""</span>,<br /><span style="color: #008000; font-weight: bold;">"imageUrl"</span>: <span style="color: #008000; font-weight: bold;">"http://www.somelink.com/file.jpg"</span>,<br /><span style="color: #008000; font-weight: bold;">"date"</span>: <span style="color: #008000; font-weight: bold;">"1457608782000"<br /></span>},<br />{<br /><strong><span style="color: #008000;">"type"</span>: <span style="color: #008000;">"CC"</span>,<br /><span style="color: #008000;">"Id"</span>: <span style="color: #008000;">"114"</span>,<br /><span style="color: #008000;">"service"</span>: <span style="color: #000080;">true</span>,<br /><span style="color: #008000;">"description"</span>: <span style="color: #008000;">""</span>,<br /><span style="color: #008000;">"imageUrl"</span>: <span style="color: #008000;">"http://www.somelink.com/file.jpg"</span>,<br /><span style="color: #008000;">"date"</span>: </strong><span style="color: #008000;"><strong>"1457611015000"</strong><br /></span>}]<br />}<br />})</pre></pre>I've learnt a little about json, got to know what arrays and objects are but still stuck with my C# app.</div><div style="font-size: 12pt;">Please guys, I need slight help with my code. I'm really stuck with it : (</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">On the click of the button I am looking to retrieve json data from the above file, which will be on the external web address: http://www.mydomain.com/mydata.json</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">By the way, I don't need all of the data. I'm looking to retrieve all json object data from <strong>"type":"CC"</strong> part only (in this case 3rd object).</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">I'm using json.net;</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">Another thing. Sometimes, mydata.json file might generate 3rd object "type":"CC" below twice or three times. However, the ID part on that CC will always be different.</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">{<br /><strong><span style="color: #008000;">"type"</span>: <span style="color: #008000;">"CC"</span>,<br /><span style="color: #008000;">"Id"</span>: <span style="color: #008000;">"114"</span>,<br /><span style="color: #008000;">"service"</span>: <span style="color: #000080;">true</span>,<br /><span style="color: #008000;">"description"</span>: <span style="color: #008000;">""</span>,<br /><span style="color: #008000;">"imageUrl"</span>: <span style="color: #008000;">"http://www.somelink.com/file.jpg"</span>,<br /><span style="color: #008000;">"date"</span>: </strong><span style="color: #008000;"><strong>"1457611015000"</strong><br /></span>} </div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">If that to happen, I only need to retrieve data from the last "CC" object in this case.</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">Another case might happen is that sometimes mydata.json file will generate only first two objects "AA" and "BB". If this happens (IF type "CC" is not printed) I need in the code to have IF() statement, to determine what to do.</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">I very much need C# code to confirm (perhaps "success" label) that mydata.json content is loaded successfully before it will be shown on the window.</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">Please guys, can someone help me with the code bit? I need something simple, less messy.</div><div style="font-size: 12pt;"> </div><div style="font-size: 12pt;">I won't be able to give you a hug or contribute towards for your help, but definitely guarantee a genuine "Thank you" from a stranger. Hope this matters. </div><div style="font-size: 12pt;"></div>
Reply
Answers (
6
)
Unable to download excel file extracted from our application
Methods concept