![]() ![]() * Float values like Infinity or NaN cannot be represented. That is enough to allow interchange.īut can you encode/decode an arbitrary integer or a float? Probably not! JSON instead offers only the representation of numbers that humans use: a sequence of digits. > JSON is agnostic about the semantics of numbers. The standard euphemistically describes this as: They can have a sign, decimal part, and an exponent. Or something could be added for convenient handling of bash arrays. For example the Python-style `%(env_var)s` sequences could be used which could expand environment variables directly. I've used a printf style format string here, which could be expanded for extra convenience. %s is invalid JSON anyway, so you can do a string substitution - all you need to keep track of are matching quotes (including escape sequences). Curl doesn't actually need to parse (nor validate) the JSON, or to create a tree representation of the data within itself. What's on the command line resembles what's actually going to be sent.Ģ. One alternative would be to provide escaping more directly like this:Īnd then curl would do the substitution with the appropriate type-specific escaping for each variable. It seems the goal is to make it easier to craft JSON by having curl perform escaping, while the proposal would seem to require some sort of in-memory tree representation of the data. I write many single purpose utilties for own use, including one that replaces the "post" shell script in this comment. ![]() large scripting language interpreters and/or other large binaries, is in short supply and 2. Printf "%s\r\n\r\n%s\r\n" "$y: close" "$x" fi īased on personal experience as an end user, I find that using separate utilities is faster and more flexible than curl or similar program mentioned in this thread. "Content-Type: application/x-www-form-urlencoded" \ It is smaller and faster, IME as a non-developer. There is a different way, without curl or other curl-like programs, without Python, Go, or the like. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |