• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSON: text limits  RSS feed

 
Kat Deere
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

My question is about limits in JSON object. If one of the values in a key value pair is just long text, is there a limit of the size of this text?
This JSON object will be used in REST APIs for system to system communication.

Example: object "game"

"game" : {
"game_name": "Some game";
"status": "in development";
"game_rules" : "very long text here"
}

Please share your ideas.

Thank you!
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no limit in size. Every key is an Object and every value is an Object. There will not be such limit.
In general, you will not get any issues if you use large size of text in JSON. But you may see the error, if your application is running out of memory(such as OutOfMemory error).
 
Kat Deere
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@rk sharma,

Thank you for your response. My concern is using this JSOn in REST APIs. We are designing APIs and one of the the calls we will be making is GET to retrieve order information. When order information is returned (again, in JSOM format), one of the key value pairs is "terms and conditions" where the value is just a very long text (essentially, a string), so I was wondering if this would be an issue.
Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unlikely. If a terms of service agreement exceeds available memory, it needs to be rewritten.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You better pre-check that very long text for punctuation, especially quote marks, which could throw JSON parsing off.

If somebody is writing those terms and conditions using MS Word - watch out for "smart" punctuation which might look ok on the screen but not what you expect in actual character value.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. Using a JSON writer, rather than trying to build it yourself, is the best way to make sure that the JSON is valid.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!