Dan Cranney
Tips and Tricks for Working with JSON
#1about 1 minute
Safely parse JSON and handle potential errors
Use a try-catch block around JSON.parse to gracefully handle invalid JSON and prevent application crashes.
#2about 1 minute
Create a helper function to validate JSON strings
Build a simple helper function that uses a try-catch block to return true or false, indicating if a string is valid JSON.
#3about 1 minute
Improve JSON readability with pretty printing
Use the third parameter of JSON.stringify to specify the number of spaces for indentation, making the output human-readable.
#4about 1 minute
Selectively exclude fields using a replacer function
Pass a function as the second argument to JSON.stringify to filter out sensitive or unnecessary fields by returning undefined for specific keys.
#5about 1 minute
Transform data during parsing with a reviver
Use the second parameter of JSON.parse as a reviver function to transform values, such as converting date strings into Date objects, during the parsing process.
#6about 1 minute
Create a deep clone of a JSON object
Perform a deep clone by serializing an object with JSON.stringify and then immediately deserializing it with JSON.parse to create a new, independent copy.
#7about 1 minute
Convert a JSON object to a URL query string
Create a function that iterates over an object's keys, URI-encodes the keys and values, and joins them with ampersands to form a valid query string.
#8about 1 minute
Dynamically create a JSON object from arrays
Generate a JSON object by programmatically combining an array of keys with a corresponding array of values using a loop.
#9about 1 minute
Merge multiple JSON objects into a single object
Combine two or more objects into one using the spread operator, where properties from later objects will overwrite those from earlier ones.
#10about 1 minute
Extract and flatten data from complex JSON
Use the flatMap method to efficiently iterate over an array of objects and extract nested array data into a single, flattened array.
Related jobs
Jobs that call for the skills explored in this talk.
Matching moments
11:34 MIN
Using JSON:API to focus on data, not format
API Design - Getting Started
17:41 MIN
Presenting live web scraping demos at a developer conference
Tech with Tim at WeAreDevelopers World Congress 2024
1:04:01 MIN
Exploring modern tools for web interaction and analysis
WeAreDevelopers LIVE - the weekly developer show with Chris Heilmann and Daniel Cranney
00:03 MIN
Introduction to JavaScript design patterns
10 must-know design patterns for JS Devs
25:45 MIN
JavaScript's journey from browser wars to native APIs
The State Of The Web
32:56 MIN
Decoding common javascript obfuscation techniques
Cracking the Code: Decoding Anti-Bot Systems!
19:28 MIN
Practical examples of tools using Rustdoc JSON
Reasoning about Rust: an introduction to Rustdoc's JSON format
32:41 MIN
Audience Q&A on tools, errors, and GraphQL
API Design - Getting Started
Featured Partners
Related Videos
JSON and Beyond
Douglas Crockford
The Eventloop in JavaScript - How does it work?
Christian Woerz
Tips and Tricks: CSS Pseudo Class Selectors and Pseudo Elements
Dan Cranney
10 must-know design patterns for JS Devs
Erick Wendel
Catching up on the basics you don't really need that much code
Chris Heilmann
Angular tips/tricks you can use from tomorrow on
Benedikt Starzengruber
The Art and Craft of Type Development
Michael Hladky & Stefan Baumgartner
Practice makes perfect - when it comes to RxJS
Jan-Niklas Wortmann
From learning to earning
Jobs that call for the skills explored in this talk.




{"@context":"https://schema.org/","@type":"JobPosting","title":"Javascript Developer
Properplan
Solihull, United Kingdom
Remote
GIT
DevOps
Node.js
Express
+2


Interactive Developer (Javascript, JS Libraries, MVC) &ndash
Thegiglab
Amsterdam, Netherlands
CSS
MVC
Node.js
MooTools
JavaScript








Node.js / TypeScript Engineer - Developer Tools & Libraries
Symbolica AI
Charing Cross, United Kingdom
€65K
API
Python
Node.js
TypeScript




