Open pkoppstein opened 2 years ago
Thank you. I'm already prototyping the CLI. You really put an effort into the help. May I alternatively use some parts of it?
Of course, that's why I've posted here!
;)
@halaxa -- Assuming (as I do) that the default encoder should be the PassThruDecoder, should there be an option to use the standard one? If so, what should it be called? Since the main point would be to convert JSON numbers to their PHP equivalent, I'm thinking of "--recode" or perhaps "--php". I think any any variation of encode
or decode
would be too confusing. Your thoughts?
Here's jm Version 0.0.5, which uses the PassThruDecoder to preserve numeric literals. It also has the side-effect of allowing mal-formed JSON, but maybe that's not such a bad thing?
[ EDIT: The version originally referenced (i.e., using the PassThruDecoder) can be viewed here at the jm repository ]
The jm script now has a bunch of options making it quite a handy tool for a variety of tasks. jm --help
gives detailed help. Here's the output of jm -h
:
Usage: jm [ OPTIONS ] [ FILEPATH ... ]
or: jm [-h | --help]
where JSONPOINTER defaults to '' and FILEPATH defaults to stdin, and the other options are:
-s
--array
--bigint_as_string | --recode
--count | --limit=LIMIT
--pointer=JSONPOINTER
Thanks for the hints. The count option is a good idea. The version I'm currently working on will also include tests and offer extensibility to some degree. I hope the PR will land soon. I'll appreciate your feedback then.
I'm adding a --version option to jm and would like to include the JSON Machine version number, but I don't see an easy way to report it reliably. Searching for the version string in CHANGELOG.md doesn't seem either efficient or reliable.
Could perhaps JSON Machine provide a function to report its version number?
@halaxa asked me to start a new thread stemming from the discussion at https://github.com/halaxa/json-machine/issues/73
Hopefully the script described below, which I'll call jm, will provide a basis for discussion or perhaps even the foundation of a script worthy of inclusion in the JSON Machine repository.
The --help option produces quite extensive documentation, so for now I'll just add two points:
[ EDIT: The
jm
script is now in the "jm" repository. ]