Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by BryanAI · Jan 11, 2012 at 04:04 PM · androidfacebookjsonhashtable

How to parse Json file in android?

Thanks to any response.

I've met some problem with parse the Json file of Facebook's Graph API in Unity, the codes can run well in the platform of PC but of Android, it met with some error code as " Type 'Object' doesn't support slicing", the codes below is what I used to parse the Json file of Facebook

=====================

import System.Globalization;

var url :String =""; private var encoding: System.Text.UnicodeEncoding;

function Start () { // Start a download of the given URL var www : WWW = new WWW (url);

 // Wait for download to complete
 yield www;

 var t1: String=convertEscString(www.text);
 var hh: Hashtable = eval(t1);

 for (var i: int=0; i<hh["data"].length; i++)
 {
     Debug.Log("name="+hh["data"][i]["name"]+" id="+hh["data"][i]["id"]);
 }

}

====================

the problem seems like Unity with Android platform cannot work with the Object of Hashtable?

Really really wanna some help to make Unity android work with JSON well, thanks to any response and help.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by rabbitfang · Jan 12, 2012 at 05:28 AM

I believe your issue is with the line var hh: Hashtable = eval(t1);. The eval() function takes a string, parses the code contained within, executes the code, and then returns the result. The result that is returned has an unknown type at compile time. As the Android and iOS platforms require that all data types be known at compile time, the eval() function is not supported on iOS or Android (reference).

You will need to code your own parser for JSON, or use one that already exists (see MiniJSON).

Comment
Add comment · Share
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
avatar image
0

Answer by BryanAI · Jan 12, 2012 at 11:49 AM

Thanks a lot, I will try to figure these out

Comment
Add comment · Share
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
avatar image
0

Answer by fuzzyduckling · Aug 23, 2012 at 08:20 PM

Did anyone figure this out? searched everywhere... this is the closest

Comment
Add comment · Share
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

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

8 People are following this question.

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

Related Questions

How to refer to internal json file on Android? 1 Answer

Unity Facebook integration for android 0 Answers

Turning off SSO on Facebook's Unity SDK for Android 0 Answers

Android + Facebook SDK 0 Answers

Hello guys i am new in using Facebook in unity 0 Answers


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