JavaScript and JSON Essentials
4.5/5
()
About this ebook
The exchange of data over the Internet has been carried out since its inception. Delimiter-separated lists such as CSV and tag-separated languages such as XML are very popular, yet they are considered to be verbose by a section of developers. JSON (JavaScript Object Notation) is a lightweight text-based code to create objects to transfer data over the Internet. It is a data exchange format that is human-readable (like XML, but without the markup around your actual payload) and its syntax is a subset of the JavaScript language that was standardized in 1999.
JavaScript and JSON Essentials is a step-by-step guide that will introduce you to JSON and help you understand how the lightweight JSON data format can be used in different ways either to store data locally or to transfer data over the Internet. This book will teach you how to use JSON effectively with JavaScript.
This book begins with a brief refresher course on JavaScript before taking you through how JSON data can be transferred via synchronous, asynchronous, and cross-domain asynchronous HTTP calls. JSON is not just about data transfer; this book throws light on the alternate implementations of JSON as well.
You will learn the data types that JavaScript uses and how those data types can be used in JSON. You will go through the concepts of how to create, update, parse, and delete a JSON object. You will also look at the different techniques of loading a JSON file onto a web page, how to use jQuery to traverse through an object, and how to perform access operations. You will also go over a few resources that will make debugging JSON quick and easy.
ApproachThe book follows a tutorial-based approach and will teach you how to work with JSON tools, design JSON objects, and how to use different techniques to handle JSON data.
Who this book is forThis book is a great resource for developers who would like to learn more about JSON and who wish to apply it in their own projects. It will be useful to have some prior knowledge of HTML and JavaScript to help you understand the concepts covered in this book. Some familiarity with a server-side language such as PHP, C#, or Python would also be beneficial, but this is not compulsory.
Sai Srinivas Sriparasa
" Sai Srinivas Sriparasa is a web developer and an open source evangelist living in the Stamford area. Sai was the lead developer for building Dr. Oz’s website, and has led teams for companies such as Sprint Nextel, West Interactive, and Apple. Sai’s repertoire includes JavaScript, PHP, Python, HTML5, responsive web development, ASP.NET, C#, and Silverlight."
Related to JavaScript and JSON Essentials
Related ebooks
JavaScript Unlocked Rating: 5 out of 5 stars5/5Mastering JavaScript Rating: 4 out of 5 stars4/5Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript Rating: 5 out of 5 stars5/5JavaScript Projects for Kids Rating: 0 out of 5 stars0 ratingsReactJS by Example - Building Modern Web Applications with React Rating: 4 out of 5 stars4/5Json for Beginners: Your Guide to Easily Learn Json In 7 Days Rating: 3 out of 5 stars3/5Mastering JavaScript Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsNode.js By Example Rating: 2 out of 5 stars2/5Learning jQuery 3 - Fifth Edition Rating: 0 out of 5 stars0 ratingsMastering JavaScript Design Patterns - Second Edition Rating: 5 out of 5 stars5/5React Projects: Build 12 real-world applications from scratch using React, React Native, and React 360 Rating: 0 out of 5 stars0 ratingsJavaScript Regular Expressions Rating: 3 out of 5 stars3/5React Design Patterns and Best Practices Rating: 0 out of 5 stars0 ratingsMastering Bootstrap 4 Rating: 5 out of 5 stars5/5TypeScript Essentials Rating: 4 out of 5 stars4/5Express Web Application Development Rating: 3 out of 5 stars3/5Getting Started with React Rating: 0 out of 5 stars0 ratingsGetting Started with React Native Rating: 4 out of 5 stars4/5Django Design Patterns and Best Practices Rating: 5 out of 5 stars5/5Learning AngularJS Animations Rating: 4 out of 5 stars4/5Jasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsLearning HTML5 by Creating Fun Games Rating: 4 out of 5 stars4/5Building Web Applications with Flask Rating: 0 out of 5 stars0 ratingsModular Programming with PHP 7 Rating: 0 out of 5 stars0 ratingsRESTful Web API Design with Node.js - Second Edition Rating: 1 out of 5 stars1/5Mastering PHP Design Patterns Rating: 0 out of 5 stars0 ratingsLearning Swift Rating: 5 out of 5 stars5/5
Programming For You
Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5101 Amazing Nintendo NES Facts: Includes facts about the Famicom Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Pokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5C# 7.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsWeb Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5
Reviews for JavaScript and JSON Essentials
6 ratings1 review
- Rating: 5 out of 5 stars5/5crisply explained in simple words and pictures are very helpful. the book is not all over the place and is easy to understand.
1 person found this helpful
Book preview
JavaScript and JSON Essentials - Sai Srinivas Sriparasa
Table of Contents
JavaScript and JSON Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. JavaScript Basics
Variables in JavaScript
Arrays
Objects
The Carousel application
Summary
2. Getting Started with JSON
The Hello World program with JSON
Datatypes in JSON
Languages that support JSON
PHP
Python
Summary
3. Working with Real-time JSON
Accessing objects in JSON
Performing complex operations
Modifying JSON
Summary
4. AJAX Calls with JSON Data
Requirements for AJAX
Hosting JSON
Making your first AJAX call
Parsing JSON data
Summary
5. Cross-domain Asynchronous Requests
Making GET and POST AJAX calls with JSON data
The problem with cross-domain AJAX calls
Introduction to JSONP
Implementing JSONP
Summary
6. Building the Carousel Application
Setting up the application
Building the JSON file for the Carousel application
Creating the Carousel application with jQuery Cycle
Summary
7. Alternate Implementations of JSON
Dependency management
JSON for storing metadata
Comparisons with YAML
Summary
8. Debugging JSON
Using the developer tools
Validating JSON
Formatting JSON
Summary
Index
JavaScript and JSON Essentials
JavaScript and JSON Essentials
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2013
Production Reference: 1181013
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-603-4
www.packtpub.com
Cover image by Ravaji Babu (<ravaji_babu@outlook.com>)
Credits
Author
Sai Srinivas Sriparasa
Reviewers
Marco Lüthy
Shameera Rathnayaka
Acquisition Editor
Joanne Fitzpatrick
Lead Technical Editor
Shaon Basu
Technical Editors
Pooja Nair
Anusri Ramchandran
Amit Shetty
Ritika Singh
Copy Editors
Alisha Aranha
Brandt D’Mello
Lavina Pereira
Project Coordinator
Akash Poojary
Proofreader
Ting Baker
Indexer
Monica Ajmera Mehta
Production Coordinator
Kirtee Shingan
Cover Work
Kirtee Shingan
About the Author
Sai Srinivas Sriparasa is a web developer and an open source evangelist living in the Stamford area. Sai was the lead developer for building Dr. Oz’s website, and has led teams for companies such as Sprint Nextel, West Interactive, and Apple. Sai’s repertoire includes JavaScript, PHP, Python, HTML5, responsive web development, ASP.NET, C#, and Silverlight.
I want to convey my sincere thanks to the team at Packt Publishing for making this book possible, Shaon, Akash, and Sumeet in particular. This is my first book, so I want to thank all of the readers in advance for having taken the time to read my book. Please contact me on my LinkedIn profile http://www.linkedin.com/in/saisriparasa for networking or for any questions that you have.
My acknowledgments cannot be complete unless I thank my mom, dad, and sister for all their patience and support throughout my life. I hope you all enjoy this book and wish me luck for my next book.
About the Reviewers
Marco Lüthy is a Swiss-born creator, designer, developer, and engineer for Internet-enabled applications and has over 10 years of experience working on projects deployed over the Internet. Occasionally he likes to dabble in content creation of the written and photographic kind. Marco’s current focus is the Tokyo-based Internet media and application development firm Robotag Media, Inc., where he is co-founder and resident factotum working on making many useful, pretty things for us all to use and play with.
Shameera Rathnayaka is an Apache Axis2 committer and a PMC member, and has been actively contributing to several Apache projects for the past few years. He holds a B.Sc. Engineering (Hons) in Computer Science and Engineering from the University of Moratuwa, Sri Lanka. He first started his open source contributions with the Apache Axis2 project, where he implemented JDK 7 Enum support for Apache Axis2 as well as stream-based high performance solutions for JSON<-->XML lossless transformation. He is a Google Summer of Code participant with Apache Axis2 and Apache Airavata projects and has reviewed the book Instant GSON, Sandeep Kumar Patel, Packt Publishing.
Shameera currently works as a Software Engineer at WSO2 Inc., an open source enterprise middleware company based in Sri Lanka, where he is a member of the WSO2 Carbon team. His main research interests are in distributed computing.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt’s online digital book library. Here, you can access, read and search across Packt’s entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
JavaScript and JSON Essentials is a one-stop resource that can be used for understanding and implementing JSON in various web applications. This book provides a comprehensive insight into how JSON can