You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to pass a full JSON as an argument just like curl does with the --data-raw attribute, but seems like node(or powershell) just remove double quotes.
❯ pnpm dev validate --schema register_todo --payload '{"teste":"teste"}'>[email protected] dev C:\workspace\alyson\study\cli-test
> tsx watch src/main.ts "validate""--schema""register_todo""--payload""{teste:teste}"
// Attention on the last line where double quotes just gone.
My way to workaround through this is pass a decodeURI on JSON strigified, then in the application I decode, parse the JSON then use it. But we know that this is just too much.
PS: Already got people making a recommendation to add slashes before double quotes like '{\"teste\":\"teste\"}'(and it works) but this is not how CURL works, my goal here is just pass a real stringified JSON
The text was updated successfully, but these errors were encountered:
Each layer of parsing may need assistance to preserve the quotes that matter. Also different shells (and parsers) treat double quotes and single quotes differently.
You are expecting it to work like it does for Curl, and maybe it will if you call the tsx command directly. That would be worth trying.
One extra layer you have in full workflow is also going through pnpm (and whatever is in the script). That is an extra layer of parsing which may have an impact. There isn't a magic solution that will work for any combination of layers of parsing. Try working through each layer and see what the arguments look like after each parsing stage.
It is unlikely to be node itself that is the problem. Node just makes available the arguments it got passed without modification. Likewise, Commander just uses the arguments that node got given and does not do anything with quotes.
I'm trying to pass a full JSON as an argument just like curl does with the --data-raw attribute, but seems like node(or powershell) just remove double quotes.
Example how it does work on CURL CLI
How its running
Result
My way to workaround through this is pass a decodeURI on JSON strigified, then in the application I decode, parse the JSON then use it. But we know that this is just too much.
PS: Already got people making a recommendation to add slashes before double quotes like
'{\"teste\":\"teste\"}'
(and it works) but this is not how CURL works, my goal here is just pass a real stringified JSONThe text was updated successfully, but these errors were encountered: