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 tarek-hentati · Dec 09, 2014 at 08:49 PM · wwwjson

Parsing Json from www response

Hi,

I have webService that return to my Unity apllication a Json response. I use the www class. When I retreive he response with the response.text and I try to parse it with my JsonParser ( I use the Json.Net), it make me this error : " JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0"

When I replace the response by a static String the same that my server reply with it works fine.!!! I log the response.text from Unity to a Json Validator, it told me that isn't valide. My response began with a hiden a hidden caracter that I supposed that response of the www class add to my server reply!!! I use the Unity 4.6 is that a Bug for this version or what!? Please help!!

Comment
Add comment · Show 5
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 steakpinball · Dec 09, 2014 at 10:01 PM 0
Share

Sounds to me like an issue on the server. Sometimes the server introduces characters into the output.

avatar image thepenguinmaster · Dec 09, 2014 at 10:07 PM 0
Share

What are you using as a server?

avatar image tarek-hentati · Dec 11, 2014 at 09:00 AM 0
Share

No it isn't from the server because wen I get the response from the server not with Unity by Postman fro example the response is validate by the json validator.

avatar image tarek-hentati · Dec 11, 2014 at 09:02 AM 0
Share

Thanks Andres Fernandez the solution of retreiving the 3 byte un the beginning is working for mee!! but is weird behaviour!! Espacially that i had some webservices that used to work and when I update my Unity to 4.6 version they are broken !!

avatar image Andres-Fernandez · Dec 12, 2014 at 10:09 AM 0
Share

The problem is not just the first three bytes. The problem is that WWW.text property includes the BO$$anonymous$$ of the file (if it has BO$$anonymous$$). As JSON must be UTF8 encoded, if the file has BO$$anonymous$$ included, it is just 3 bytes long (EF BB BF), but other encodings have other BO$$anonymous$$ length.

So, if you are retrieveing a file using WWW.text and the file is UTF8 encoded, then check for the UTF8 BO$$anonymous$$ . If present, then skip those bytes.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tarek-hentati · Dec 12, 2014 at 09:42 AM

Hi, I could resolve my problem with this solution posted in this url : http://answers.unity3d.com/questions/844423/wwwtext-not-reading-utf-8-text.html

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 abi-kr01 · Dec 11, 2014 at 11:34 AM

there must be other text after your json string like

 {"user_ id":0, "token":"sdddas"} <html>bla bla bla</html>



.Json parser is trying to parse that too which is causing issue.

Comment
Add comment · Show 1 · 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 tarek-hentati · Dec 12, 2014 at 07:58 AM 0
Share

No there was some byte from the encode UTF8 that is boking my json structure. The sollution is what Andres Fernandez comment in my question

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

6 People are following this question.

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

Related Questions

Upload/store string to html/json script?? 0 Answers

Integrating Watson Speech-to-Text with Unity 1 Answer

I cant get response json from rest call in Unity 1 Answer

iPhone bad URL 0 Answers

WWW data acquisition from remote server failing 2 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