Skip to content

Commit 12c7f97

Browse files
committed
Adding some more formats and object formats
1 parent 300870d commit 12c7f97

15 files changed

+523
-26
lines changed

β€ŽREADME.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
- [Date/Time strings](#datetime-strings)
1515
- [URI strings](#uri-strings)
1616
- [Email address strings](#email-address-strings)
17+
- [JWT](#jwt)
1718
- [Other formats](#other-formats)
19+
- [Object Formats](#object-formats)
20+
- [Firestore Timestamps](#firestore-timestamps)
1821
- [Roadmap](#roadmap)
1922

2023
## πŸš€ Features
@@ -231,6 +234,8 @@ Will result in
231234
}
232235
```
233236

237+
### JWT strings
238+
234239
The following table illustrates the results of different email strings
235240

236241
| String | Variant |
@@ -250,10 +255,11 @@ The following table illustrates the rest of the formats JSON Infer Types support
250255
| `"USD"`, `"BTC"` | currency | iso4217 |
251256
| `"United States dollar"`, `"Euro"` | currency | english |
252257
| `"ETH"`, `"LTC"` | currency | crypto |
258+
| `'$'`, `'Β£'`, `'€'`, `'Β₯'` | currency | symbol |
253259
| `"USA"`, `"MMR"` | country | iso3166-3 |
254260
| `"US"`, `"GB"`, `"JP"` | country | iso3166-2 |
255261
| `".com"`, `".co.uk"`, `".biz"` | tld | |
256-
| `"192.168.0.1"`, `"172.16.0.0"`, `".biz"` | ip | v4 |
262+
| `"192.168.0.1"`, `"172.16.0.0"` | ip | v4 |
257263
| `"2001:db8:1234::1"` | ip | v6 |
258264
| `"en"`, `"ab"`, `"es"` | language | iso693-1 |
259265
| `"eng"`, `"eus"`, `"zul"` | language | iso693-2 |
@@ -268,6 +274,40 @@ The following table illustrates the rest of the formats JSON Infer Types support
268274
| `"544B"`, `"1.0MB"`, `"377K"`, `"1.87GB"` | filesize | human |
269275
| `'{ "foo": 1 }'` | json | ecma262 |
270276
| `'{ foo: 1, }'` | json | json5 |
277+
| `"/foo/bar"`, `"/foo/-/bar"` | jsonPointer | rfc6901 |
278+
| `"0/foo/bar"`, `"2/0/baz/1/zip"` | jsonPointer | relative |
279+
| `"πŸ˜„"`, `"πŸ€ͺπŸ‘¨πŸ½β€πŸš€"`, `"πŸ‘©β€πŸ‘©β€πŸ‘§β€πŸ‘§"` | emoji | |
280+
| `"1.11.0"`, `"0.0.1"`, `"1.0.0-alpha.1"` | semver | |
281+
282+
## Object Formats
283+
284+
We also infer the format of certain common object shapes, documented below:
285+
286+
### Firestore Timestamps
287+
288+
[Firestore Timestamps](https://firebase.google.com/docs/reference/node/firebase.firestore.Timestamp) are an object with two keys, `_seconds` and `_nanoseconds`:
289+
290+
```json
291+
{
292+
"_seconds": 1642533020,
293+
"_nanoseconds": 932000000
294+
}
295+
```
296+
297+
Inferring this object will result in the following inferred type:
298+
299+
```json
300+
{
301+
"name": "object",
302+
"value": {
303+
"_seconds": 1642533020,
304+
"_nanoseconds": 932000000
305+
},
306+
"format": {
307+
"name": "firestoreTimestamp"
308+
}
309+
}
310+
```
271311

272312
Please feel free to request additional formats by opening a [Github issue](https://github.com/jsonhero-io/json-infer-types/issues)
273313

0 commit comments

Comments
Β (0)