• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about null values in JSON

 
Greenhorn
Posts: 25
Mac OS X Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know how to represent null values in JSON?
I've found this but it doesn't seem to work.

 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Start by telling us what are you trying to do. json file on its own is just a text file. Such term as "doesn't work" just doesn't make sense on its own when you talking about text file.

Are you trying to check if it is well formed json file or to check it against json schema?
Or you might trying to extract data with jQuery AJAX or something else?

Please be very specific in your questions, so someone could help you. Failing to do so, can result in not getting any replies or getting small amount. People are tend to help here when posters helping to understand the problem well.

Please provide more information. Thank you.
 
Martin Bluck
Greenhorn
Posts: 25
Mac OS X Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks and apologies for not being clear.
What I meant by "it doesn't work" was that it doesn't validate (against jsonlint.com).
I'm trying to find a valid way of displaying null values in JSON, I can understand XML but I'm finding JSON difficult to understand.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the right way. Enclose it in {} and it'll validate on jsonlint.
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is JSON? JavaScript Object Notation.
And how object is defined? In between curly braces. So all text you have needs to be wrapped with an object notation.

And once you're getting confused with your JSON structure, indent it properly, so you'd have it in so called development form and not production.

Try to validate again and see what happens.
 
Martin Bluck
Greenhorn
Posts: 25
Mac OS X Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That makes sense now, thanks to both of you.
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Bluck wrote:That makes sense now, thanks to both of you.

You are most welcome
 
reply
    Bookmark Topic Watch Topic
  • New Topic