Web Tools #536 - JSON Reviver, CSS Tools, Testing, JS Utilities

Web Tools Weekly
WEB VERSION
Tools for Web Developers

Issue #536 • October 26, 2023

Advertisement

Webflow, the Only Visual Development Platform Designed for Agencies
Be the one clients can’t stop talking about. Trusted by 60,000+ freelancers and agencies, Webflow allows you to build custom websites visually, manage projects in a shared dashboard and collaborate with your colleagues.

Webflow

Take control of HTML, CSS, and JavaScript in a visual canvas. Webflow generates clean, semantic code that’s ready to publish or hand to developers.

Get Started – it's Free →

 
 

A lot of developers have used JavaScript's JSON.parse() method when dealing with JSON objects, but for a long time may not have known about the optional second argument you can pass into it.

The second argument for JSON.parse() is referred to as a reviver function. If it was named today, I'm guessing it would have a different name, maybe filter or something similar. This function allows you to transform the fully parsed JSON values returning them.

For example, let's say we have the following JSON object:

{
  "species": "Cat",
  "breed": "Labrador Retriever",
  "age": 6,
  "traits": {
    "eyeColor": "brown",
    "coatColor": "yellow",
    "weight": "137lbs"
  }
}

This JSON comes in as a string, so I use JSON.parse() to convert it to a proper JSON object. In the meantime, I want to make a correction to one of the values. Below is the code (with myNewJSON as a string holding the JSON from above that gets parsed):

let myNewJSON = JSON.parse(myJSON, function (key, value) {
  if (key === "species") {
    value = "Dog";
  }
  return value;
});

That's just a simple example using the reviver function. Most practical examples might be some form of calculation on values or something else more complex than just a value check. You can basically do whatever you want to transform the values.

You can try out the above code example in this CodePen. Feel free to fork it and mess around with some other types of transformations.

The rules that apply when using the reviver are as follows:

  • The reviver function takes two arguments, representing the key and value for each key/value pair in the parsed JSON string.
  • If during the transformation a key/value pair returns undefined, this key/value pair is deleted from the parsed JSON when it's returned.
  • You have to make sure all values are returned, even the ones you don't transform, otherwise they'll be deleted from the returned JSON object.
  • Technically you can return anything in the reviver function, and whatever you return will replace what was originally attempted to parse. So it seems in all (or most?) cases you'll be returning the value of each property/value pair after you've done your transformation.
  • When there's nested JSON key/value pairs, the values are returned based on depth-first searching. So if you log each "key" before returning, you'll see the order they come back in. You can try this by uncommenting the line inside the if statement in the CodePen.
Was this feature of JSON.parse() new to you? Seems to be a lesser-known feature of manipulating JSON, and maybe you'll find it useful when parsing JSON content in your apps.

Now on to this week's tools!
 

CSS and HTML Tools

TailwindMate
An online tool to convert RGB(A), HSL(A), or Hex format to the closest Tailwind utility class equivalent for that color. You can also convert from Tailwind to those CSS formats.

CSS Size Analyzer
An online tool to analyze CSS size to help you catch bloat from things like embedded images or fonts.

CSS Size Analyzer

Build a Better Mobile Input
An interactive tool to experiment with and edit various form input attributes that are beneficial for mobile usability, with a live view of an iOS or Android device to see the results.

Webflow, the Only Visual Development Platform Designed for Agencies
Be the one clients can’t stop talking about. Build custom websites visually, manage projects in a shared dashboard and collaborate with your colleagues all with Webflow.     SPONSORED 

selectors.info
A simple interactive tool, mostly for CSS beginners, to learn all the different CSS selectors visually.

tw2panda
A CLI tool and VS Code extension to easily migrate code from Tailwind to Panda CSS. Also includes an online playground to try it out on a web UI.

table-saw
A small structural-only zero-dependency Web Component for responsive HTML table elements, inspired an old jQuery plugin with a similar name.

vov.css
A CSS library of about 60+ useful CSS animations that you can add to elements by class name and you can try out each one directly on the page.

@unpic/placeholder
A JavaScript utility that generates pure-CSS placeholder images by extracting the dominant color from an image, or by server-side rendering a BlurHash value.

Gradient Designer
An interactive tool to generate CSS gradients using visual color stops and with support for modern color spaces (sRGB, Oklab, etc).
 

Testing and Debugging Tools

Insomnium
A 100% local and privacy-focused open-source API client for testing GraphQL, REST, WebSockets, Server-sent events, and gRPC in development/production.

Quick JavaScript Switcher
Chrome extension. A quick way to disable/enable JavaScript in the browser, with the ability to limit to a subdomain or hostname.

MiniSim
An open-source, lightweight, native Mac menubar app that allows you to quickly launch iOS and Android emulators.

Remix Development Tools
A toolkit for working with Remix applications, to efficiently monitor and manage various aspects of your Remix projects, including page information, URL parameters, server responses, loader data, routes, and more.

The Morning Paper for Tech
Want a byte-sized version of Hacker News that takes just a few minutes to read? Try TLDR's free daily newsletter. It covers the most interesting tech, startup, and programming stories in just 5 minutes. No sports and no politics.    SPONSORED 

presentable-error
Work in progress. A convention for presenting errors without a stack trace, which can be useful for command line tools.

HyperDX
An open-source observability platform unifying session replays, logs, metrics, traces and errors, a developer-friendly alternative to Datadog and New Relic.

HyperDX

Rivet
A browser extension that enables developers to inspect, debug, modify, and manipulate the state of Ethereum: accounts, blocks, contracts, and the node itself.

Social Share Preview
An online tool to test how your social cards will look when shared on various platforms (X, Facebook, LinkeIn, Pinterest).

RecipeUI
An open-source Postman alternative with type safety built in. Catch your API requests before they fail with TypeScript and autocomplete. Enhance your workflows with auto-generated docs and reusable API templates.

why-is-node-running
A Node.js package or CLI tool that lets you check to see if Node is running and why.
 

JavaScript Utilities

TanStack Store
A framework-agnostic, type-safe state management store with framework specific adapters for major frameworks like React, Solid, Vue, and Svelte.

Crystalize.js
A reducer on steroids, where state management gets a transformative twist, but if reducers had undo/redo and time-travel.

Lucia
An auth library for TypeScript that abstracts away the complexity of handling users and sessions and works alongside your database to provide an API that's easy to use, understand, and extend.

autocomp.js
A super tiny JavaScript autocomplete library with zero dependencies and  weighs in at about 800 bytes minified and gzipped.

autocomp.js

Sugar High
A super-lightweight JSX syntax highlighter, around 1KB after minified and gzipped.

The Morning Paper for Tech
Want a byte-sized version of Hacker News that takes just a few minutes to read? Try TLDR's free daily newsletter. It covers the most interesting tech, startup, and programming stories in just 5 minutes. No sports and no politics.    SPONSORED 

@exact-realty/lot
A versatile ECMAScript sandbox that supports multiple runtimes and allows for bidirectional communication, for flexibility and security to run your code in various environments.

blog-cells
Embed interactive code cells to any web page, similar to Jupyter Notebooks. Works with static site generators like Jekyll, Hugo, and more.

@badrap/valita
A TypeScript library for validating and parsing structured objects, heavily influenced by Zod's API, with strong performance on the implementation side.

Calendar.js
A JavaScript drag-and-drop event calendar that's fully responsive and compatible with all modern browsers.

IterTools
Inspired by Python and designed for TypeScript, a package that provides two types of iteration tools: loop iteration and stream iteration.
 

Commercial Apps and Classifieds

These are commercial apps, affiliate links, PPC ads, and paid classifieds. Buy a Classified here.
SearchApi – A Google search API
and real-time SERP API for easy SERP scraping.
Bytes – A JavaScript newsletter that's informative and entertaining, for all levels of JS devs.    AD 
Seoship – An SEO toolkit for indie hackers with tools for on-page SEO, backlinks, keywords, and more.
Bugfender – A log storage service that collects everything  that happens in your applications.
Hal9 – Answer data questions with conversational AI that leverages your company's cloud data.   AD 
Contza – A developer-first CMS platform that makes it as easy to add a CMS to your website.
Record – Automatically capture user sessions or allow your users to record issues along with all data.

An X Post for Thought

Not easy to do, but this is excellent advice that would likely be great for your physical and mental health.
 
An X Post for Thought
 

Send Me Your Tools!

Made something? Reply to this email or send links via Direct Message on X @LouisLazaris (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.
 

Before I Go...

How many music genres are there? Well, according to Every Noise at Once, that's not easy to define. This website describes itself as "an ongoing attempt at an algorithmically-generated, readability-adjusted scatter-plot of the musical genre-space, based on data tracked and analyzed for 6,282 genre-shaped distinctions by Spotify."  There's quite a bit to experiment with here, besides just clicking on any genre to hear a snippet. This is a great way to find new artists!

Thanks to everyone for subscribing and reading!

Keep tooling,
Louis
@LouisLazaris
PayPal.me/WebToolsWeekly

Older messages

Web Tools #535 - JS Libraries, ChatGPT Tools, React Native

Thursday, October 19, 2023

Web Tools Weekly WEB VERSION Issue #535 • October 19, 2023 Advertisement Webflow, the Only Visual Development Platform Designed for Agencies Be the one clients can't stop talking about. Trusted by

Web Tools #533 - MDN RegExp, CSS Tools, ChatGPT, JSON/DB

Thursday, October 5, 2023

Web Tools Weekly WEB VERSION Issue #533 • October 5, 2023 Advertisement Webflow, the Only Visual Development Platform Designed for Agencies Be the one clients can't stop talking about. Trusted by

Web Tools #532 - Guitar Tools, React, SVG, Uncats

Thursday, September 28, 2023

Web Tools Weekly WEB VERSION Issue #532 • September 28, 2023 Advertisement Let Auth0 by Okta Take Care of Customer Identity Got better things to worry about than building Identity? If you're an

Web Tools #531 - Video SDK, JS Utilities, Build Tools, VS Code

Thursday, September 21, 2023

Web Tools Weekly WEB VERSION Issue #531 • September 21, 2023 The following intro is a paid product review for Dyte, a platform that provides a powerful SDK to create immersive live video experiences

Web Tools #530 - DOM Parser, Frameworks, Media Tools, JS Plugins

Sunday, September 17, 2023

Web Tools Weekly WEB VERSION Issue #530 • September 14, 2023 Advertisement They Call it the “Tesla of Productivity Apps" Achieve maximum productivity with: Daily planning: Add or create a daily

You Might Also Like

Issue #568: Random mazes, train clock, and ReKill

Friday, November 22, 2024

View this email in your browser Issue #568 - November 22nd 2024 Weekly newsletter about Web Game Development. If you have anything you want to share with our community please let me know by replying to

Whats Next for AI: Interpreting Anthropic CEOs Vision

Friday, November 22, 2024

Top Tech Content sent at Noon! How the world collects web data Read this email in your browser How are you, @newsletterest1? 🪐 What's happening in tech today, November 22, 2024? The HackerNoon

iOS Cocoa Treats

Friday, November 22, 2024

View in browser Hello, you're reading Infinum iOS Cocoa Treats, bringing you the latest iOS related news straight to your inbox every week. Using the SwiftUI ImageRenderer The SwiftUI ImageRenderer

iOS Dev Weekly - Issue 688

Friday, November 22, 2024

How do you get an app featured on the App Store? There's a new process, and it's great! 📝 View on the Web Archives ISSUE 688 November 22nd 2024 Comment Every developer, from solo indie devs to

Why Nvidia's CEO loves NotebookLM

Friday, November 22, 2024

I love my Alexa-enabled microwave; Best early Black Friday deals -- ZDNET ZDNET Tech Today - US November 22, 2024 Jensen Huang Even Nvidia's CEO is obsessed with Google's NotebookLM AI tool

Digest #151: Uber’s Migration, Terraform Tips, AMI Creation, and Helm Chart Scanning

Friday, November 22, 2024

Learn zero-downtime migration techniques, improve testing workflows, and master AMI creation. Plus, explore Terraform tools, Helm chart validation, and debugging AWS EC2 issues. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

SWLW #626: AI makes Tech Debt more expensive, The problem with most L&D strategies, and more.

Friday, November 22, 2024

Weekly articles & videos about people, culture and leadership: everything you need to design the org that makes the product. A weekly newsletter by Oren Ellenbogen with the best content I found

Warning: Over 2,000 Palo Alto Networks Devices Hacked in Ongoing Attack Campaign

Friday, November 22, 2024

THN Daily Updates Newsletter cover Generative AI For Dummies ($18.00 Value) FREE for a Limited Time Generate a personal assistant with generative AI Download Now Sponsored LATEST NEWS Nov 22, 2024

⚙️ Businesses increase AI spend to $13.8 billion

Friday, November 22, 2024

Plus: World leaders endorse digital green action plan ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Post from Syncfusion Blogs on 11/22/2024

Friday, November 22, 2024

New blogs from Syncfusion Building Oqtane Modules with Syncfusion Components for Blazor [Webinar Show Notes] By Carter Harris This blog provides show notes for our Nov. 14, 2024, webinar, “Building