Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
JavaScript and JSON Essentials

You're reading from   JavaScript and JSON Essentials If you fancy a less verbose data format than CSV or XML, then JSON could be for you. This tutorial will teach you about using JSON with JavaScript for effective local storage or Internet transfers.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781783286034
Length 120 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sai S Sriparasa Sai S Sriparasa
Author Profile Icon Sai S Sriparasa
Sai S Sriparasa
Arrow right icon
View More author details
Toc

Validating JSON


Similar to our debugging resources, there are a lot of popular web tools that help us with validating JSON that we build. JSONLint is one of the most popular web tools that are available for validating our JSON feeds.

Note

When we are using a server-side program such as PHP, Python, or Java, the built-in JSON encoding libraries generate the JSON feed, and normally the feed will be a valid JSON feed.

JSONLint has a very straightforward interface that allows the user to paste the JSON they want to validate, and returns either a success message or an error message based on the JSON feed that we paste. Let us begin by validating a bad piece of JSON to see the error message that would be returned, and then let us fix it to view the success message. For this example, I will copy the students feed from the previous example, and add a trailing comma at the end of the second element:

Notice that we have added a trailing comma to the last item in our JSON object, and the best part about...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image