Confused about getting valid JSON from a query

I confess I’m confused about how I generate valid JSON from a query. I’ve found all manner of opinions online about what I need to do to serialize but the details arent all that obvious to me. Perhaps i’m not clear headed enough this year.

Anyway, here’s what I’m trying to do :
{1} Use a CFC to run a query in a method. (All my database interactions are done from a CFC)
(2) serialize the result into valid JSON to pass back to the calling page,
(3) Use javascript to manipulate the resulting data. (This is in order to use AJAX to update the page without requiring refresh)

I can handle the CFQUERY part - i’ve been doing that since 1996. It’s the next steps I’m not clear about.
Data = serialize(queryname) just seems to give me errors - particularly Too many Attributes (1:2) in function call [serialize]

Serialize(queryname) gives an error that refers to a struct being unable to be serialized.
serialize(queryname, ‘struct’ ) gives an error too many attributes.

Is there any documentation that is a bit more fullsome than the brief syntax on the serialize tag?

Or anything else that might help me get my head around what i need to do?

Mike Kear
Windsor, NSW, Australia

@mikek Use SerializeJSON() instead of Serialize(). Serialize() is not always returns the JSON result.

Serialize() :: Lucee Documentation

SerializeJSON() :: Lucee Documentation