Is there a Lucee replacement for createObject("jav...
# cfml-general
g
Is there a Lucee replacement for createObject("java", "coldfusion.util.HTMLTools").parseQueryString(stringToParse) ?
b
The ColdBox framework does this if I recall. It's only a few lines of code to write a query string parsing function
According to CoPilot, the JDK doesn't have anything pre-built for this
👍 1
Here's some code I found
Copy code
var virtualRC = {};
				args.listToArray( "&" )
					.each( function( item ){
						virtualRC[ item.getToken( 1, "=" ).trim() ] = urlDecode( item.getToken( 2, "=" ).trim() );
					} );
though I'd rewrite it to use reduce() and not modify any external struct
funny because that's about 10 times less code than the Java code CoPilot gave me when I asked if the JDK had a way to do this, lol
👍🏼 1
g
Co-pilot is useful as a resource. But I don't find myself using what it suggests, verbatim. There always seems to be a "better" way to do it. And I don't just mean in the context of "my" application - or from a perspective of what "I" prefer... But in a "general-ness" (word I just made up!) ... it offers a lot of code that looks like my "early" solutions to problems. Which I suppose is telling in the sense of how much "shitty" code is out there - that it has learnt from - that it now offers as "the" solution to a given problem.
b
Yeah, I'd say copilot is wrong in int's initial answer about 50% of the time. It's still useful and can write menial stuff for me, but if I had a dollar every time I've told it "yeah, that's not right" and then it apologizes, I'd have a lot of dollars.
👍🏼 1
👍 1
g
I use it as a guide.... Eg - lets just assume that I have completely forgotten how to write a bubble-sort... I'll just ask co-pilot to do it for me.... Then - ion reading the suggestion - the way "I Know" - normally follows, pretty quickly. In this land of remote work since covid - I use it as a wall to bounce thoughts (and prayers 🙂 ) off!
👍 1
g
I like how it at least pretends to be nice.
👍🏼 1