mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2026-04-26 21:04:16 +02:00
doc update
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.iso_datetime"></a>
|
||||
|
||||
# jc.parsers.iso\_datetime
|
||||
|
||||
jc - JSON Convert ISO 8601 Datetime string parser
|
||||
|
||||
This parser supports standard ISO 8601 strings that include both date and
|
||||
time. If no timezone or offset information is available in the sring, then
|
||||
UTC timezone is used.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('iso_datetime', iso_8601_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"year": integer,
|
||||
"month": string,
|
||||
"month_num": integer,
|
||||
"day": integer,
|
||||
"weekday": string,
|
||||
"weekday_num": integer,
|
||||
"hour": integer,
|
||||
"hour_24": integer,
|
||||
"minute": integer,
|
||||
"second": integer,
|
||||
"period": string,
|
||||
"utc_offset": string,
|
||||
"day_of_year": integer,
|
||||
"week_of_year": integer,
|
||||
"iso": string,
|
||||
"timestamp": integer
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
|
||||
{
|
||||
"year": 2022,
|
||||
"month": "Jul",
|
||||
"month_num": 7,
|
||||
"day": 20,
|
||||
"weekday": "Wed",
|
||||
"weekday_num": 3,
|
||||
"hour": 2,
|
||||
"hour_24": 14,
|
||||
"minute": 52,
|
||||
"second": 45,
|
||||
"period": "PM",
|
||||
"utc_offset": "+0000",
|
||||
"day_of_year": 201,
|
||||
"week_of_year": 29,
|
||||
"iso": "2022-07-20T14:52:45+00:00",
|
||||
"timestamp": 1658328765
|
||||
}
|
||||
|
||||
<a id="jc.parsers.iso_datetime.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
+67
-5
@@ -5,6 +5,18 @@
|
||||
|
||||
jc - JSON Convert URL string parser
|
||||
|
||||
This parser will work with naked and wrapped URL strings:
|
||||
|
||||
- `scheme://host/path`
|
||||
- `URL:scheme://host/path`
|
||||
- `<scheme://host/path>`
|
||||
- `<URL:scheme://host/path>`
|
||||
|
||||
Two query representations are available and documented in the schema.
|
||||
|
||||
Normalized quoted and unquoted versions of the original URL are also
|
||||
included.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ echo "http://example.com/test/path?q1=foo&q2=bar#frag" | jc --url
|
||||
@@ -17,12 +29,25 @@ Usage (module):
|
||||
Schema:
|
||||
|
||||
{
|
||||
"quoted": string,
|
||||
'unquoted": string,
|
||||
"scheme": string,
|
||||
"netloc": string,
|
||||
"path": string or null,
|
||||
"query": { object or null,
|
||||
<query-key>: string
|
||||
"path_list": [ array or null
|
||||
string
|
||||
],
|
||||
"query": { object or null
|
||||
<query-key>: [ array or null
|
||||
<query-value> string # [0]
|
||||
]
|
||||
},
|
||||
"query_list": [ array or null
|
||||
[
|
||||
<query-key> string, # [1]
|
||||
<query-value> string
|
||||
]
|
||||
],
|
||||
"fragment": string or null,
|
||||
"username": string or null,
|
||||
"password": string or null,
|
||||
@@ -30,17 +55,48 @@ Schema:
|
||||
"port": integer or null
|
||||
}
|
||||
|
||||
[0] Duplicate query-keys will have their values consolidated into the
|
||||
array of query-values
|
||||
[1] The first array value is the query-key and the second value is the
|
||||
query-value
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo "http://example.com/test/path?q1=foo&q2=bar#frag" | jc --url -p
|
||||
% echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
|
||||
| jc --url -p
|
||||
{
|
||||
"quoted": "http://example.com/test/path?q1%3Dfoo%26q1%3Dbar%26q2%3Dbaz#frag",
|
||||
"unquoted": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"scheme": "http",
|
||||
"netloc": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": {
|
||||
"q1": "foo",
|
||||
"q2": "bar"
|
||||
"q1": [
|
||||
"foo",
|
||||
"bar"
|
||||
],
|
||||
"q2": [
|
||||
"baz"
|
||||
]
|
||||
},
|
||||
"query_list": [
|
||||
[
|
||||
"q1",
|
||||
"foo"
|
||||
],
|
||||
[
|
||||
"q1",
|
||||
"bar"
|
||||
],
|
||||
[
|
||||
"q2",
|
||||
"baz"
|
||||
]
|
||||
],
|
||||
"fragment": "frag",
|
||||
"username": null,
|
||||
"password": null,
|
||||
@@ -50,10 +106,16 @@ Examples:
|
||||
|
||||
$ echo "ftp://localhost/filepath" | jc --url -p
|
||||
{
|
||||
"quoted": "ftp://localhost/filepath",
|
||||
"unquoted": "ftp://localhost/filepath",
|
||||
"scheme": "ftp",
|
||||
"netloc": "localhost",
|
||||
"path": "/filepath",
|
||||
"path_list": [
|
||||
"filepath"
|
||||
],
|
||||
"query": null,
|
||||
"query_list": null,
|
||||
"fragment": null,
|
||||
"username": null,
|
||||
"password": null,
|
||||
|
||||
Reference in New Issue
Block a user