WordPress at a glance
function is not described

wc_esc_json() WC 3.5.5

Escape JSON for use on HTML or attribute text nodes.

No Hooks.

Return

String. Escaped JSON.

Usage

wc_esc_json( $json, $html );
$json(string) (required)
JSON to escape.
$html(true|false)
True if escaping for HTML text node, false for attributes. Determines how quotes are handled.

Changelog

Since 3.5.5 Introduced.

Code of wc_esc_json() WC 5.3.0

<?php
function wc_esc_json( $json, $html = false ) {
	return _wp_specialchars(
		$json,
		$html ? ENT_NOQUOTES : ENT_QUOTES, // Escape quotes in attribute nodes only.
		'UTF-8',                           // json_encode() outputs UTF-8 (really just ASCII), not the blog's charset.
		true                               // Double escape entities: `&amp;` -> `&amp;amp;`.
	);
}