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 bmccall1 · Jun 11, 2014 at 04:09 PM · jsonapi

Can anyone recommend a json parser good for using with a web api?

I am currently using SimpleJSON and I'm trying to send the data back and forth to a webapi. Whenever I try to add nodes or send/recieve data to the API, i end up, regardless of the escape sequences with a bunch of horribly mangled data.

My big problem is, the "tostring" method that SimpleJSON impelements. It adds a lot of escaped characters like \r\n and \". I end up having to manually remove a lot of it, and don't get me started on what happens if you call WWW.EscapeURL on the string before I send it to the api.

So, rather than go on and on about how bad simplejson is, anyone have a better solution?

Thanks so much!

Comment
Add comment · Show 6
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 fafase · Jun 11, 2014 at 04:39 PM 0
Share

Is it bad or are you using it wrong? You are one of the first to say it is inappropriate.

You may also just develop your own that does just what you need. This is what I do when I need a parser since those you find online are meant to be used anywhere in any situation and may not do as good as cut-to-fit one.

avatar image bmccall1 · Jun 11, 2014 at 05:03 PM 0
Share

Hi, thanks for the response.

fafase, I don't think I'm using it wrong.

If I request a clean json object from the webapi, and parse it with simple JSON it works fine.

As a var, I can modify nodes, add nodes, and remove nodes just fine. However when I want to update the value of that node via web api, it will break.

I believe the core problem is that the method .tostring() which I have to call to construct the url for the web api injects carriage returns and marks up quotation marks.

avatar image fafase · Jun 11, 2014 at 05:10 PM 0
Share

Can't you override it to do exactly what you need?

avatar image Bunny83 · Jun 11, 2014 at 05:22 PM 0
Share

Well, you're not using it wrong ;) The problem is that i wrote it mainly as parser and not really as a full JSON framework. That's why every "value" is treated like a string value (so true, false and numbers are just treated like strings since i don't analyse or store that information at all)

I have this for quite a long time on my "todo" list. I want to implement a seperate class for the different literal values which should serialize properly. However i can't find the time, sorry ;)

avatar image bmccall1 · Jun 11, 2014 at 05:56 PM 0
Share

Hey thanks for the response Bunny83. Well, its good to know its not me. And yes, I've gotten used to the quirks of every value being a string and I just run int parse or tostring when I need to.

I am not sure if it will be easier to extend your tostring method or to find another solution. I suppose I will see what I come up with.

Thanks again for writing it, up until this point its been great.

Show more comments

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

22 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

Related Questions

A node in a childnode? 1 Answer

How to send data form to server using json in unity 1 Answer

a live updating button panel? pulling from an external api? 0 Answers

Yelp API- Latitude/Longitude parameter problem {Key/Value} 2 Answers

How do I implement Kongregate's API? 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