Re: [whatwg/url] URL.toJSON() returns a string, not an object — misleading name, consider toJSONObject (Issue #888)

annevk left a comment (whatwg/url#888)

Yeah this is very much intentional. If you want to share a URL object in some way, you need to share the serialized URL. This follows https://url.spec.whatwg.org/#url-apis-elsewhere.

An API for getting alternative JSON representations could be a thing I suppose, but I'd want TC39 to set precedent for how to go about that first. And some precedent in widely adopted libraries that show there's a real demand for this.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/888#issuecomment-3461569727
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/888/3461569727@github.com>

Received on Wednesday, 29 October 2025 13:37:27 UTC