Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Sek19 · Apr 13, 2017 at 12:56 AM · listfacebookjsondeserialization

how do you Deserialize JSON in a list?

Hello, I have a question about JSON files and Deserialization. I'm using Unity and the MinJson library to Deserialize the information passed over by the Graph API with C#. Currently I can Deserialize arrays or individual items in a format like this.

"category_list": [{"id": "205950169432461","name": "Day Spa"}] "information" : "information that this holds"

what i'm having an issue with is when the Json is in a format such as this I believe they are called lists (please correct me if I'm wrong) :

"hours"{"day one": "time", "day_two": "time2", "day_three": "time3" }

What i'm doing to deserialize is this:

 //IResult being the Json information about the page passed by the Graph API
 public void DisplayBusinessInfo (IResult result)
 {
 String JsonString = result.RawResult;
 var PageInfo = Json.Deserialize(JsonString) as Dictionary<string, object>;
 //using the array example above
 List<object> categorylist = PageInfo["category_list"] as List<object>;
 }
 try
 {
 // this for loop breaks down the list that I stored categorylist into and returns the individual items within it
 for (int i = 0; i < categorylist.Count; i++)
 {
 Dictionary<string, object> messageData = categorylist[i] as Dictionary<string, object>;
 object resultData = messageData["name"];
 Debug.Log("JSON string : " + resultData.ToString());
 //returns the information : Day Spa
 }
 catch
 {
 Debug.Log("it is done");
 }
 //anything that is not an array goes directly into this if statement. Again i'll use the example I have provided above
 if (result.Error == null)
 {
 Information = "" + result.ResultDictionary["information"];
 //Returns : information that this holds
 }

What I don't understand about the list is how it's being classified in Deserialization. I have tried passing it through as an object and string but failed on both attempts. If you could help explain what Json information in {} is and provide a link or any help on deserializing it with the format I have currently, I would greatly appreciate it!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

100 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Argument Exception: J SON must represent an object type. Serialization list of objects 0 Answers

How to read a nested Array Json File in unity 3d? 0 Answers

How do you sort a list of JSONNodes by key value? 1 Answer

How To Deserialize Json Data Into List? 1 Answer

Facebook SDK Json Parsing with foreach loop not updating 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges