headson 0.2.4__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of headson might be problematic. Click here for more details.

Files changed (48) hide show
  1. {headson-0.2.4 → headson-0.3.0}/Cargo.lock +30 -218
  2. {headson-0.2.4 → headson-0.3.0}/Cargo.toml +7 -5
  3. headson-0.3.0/PKG-INFO +168 -0
  4. headson-0.3.0/README.md +152 -0
  5. {headson-0.2.4 → headson-0.3.0}/pyproject.toml +2 -4
  6. {headson-0.2.4 → headson-0.3.0}/python/Cargo.lock +35 -227
  7. {headson-0.2.4 → headson-0.3.0}/python/Cargo.toml +2 -2
  8. {headson-0.2.4 → headson-0.3.0}/python/src/lib.rs +9 -8
  9. {headson-0.2.4 → headson-0.3.0}/src/main.rs +8 -6
  10. {headson-0.2.4 → headson-0.3.0}/src/order/build.rs +7 -1
  11. {headson-0.2.4 → headson-0.3.0}/src/order/types.rs +2 -0
  12. {headson-0.2.4 → headson-0.3.0}/src/serialization/mod.rs +81 -10
  13. {headson-0.2.4 → headson-0.3.0}/src/serialization/templates/core.rs +6 -1
  14. {headson-0.2.4 → headson-0.3.0}/src/serialization/templates/js.rs +7 -4
  15. {headson-0.2.4 → headson-0.3.0}/src/serialization/templates/mod.rs +1 -0
  16. {headson-0.2.4 → headson-0.3.0}/src/serialization/templates/pseudo.rs +3 -0
  17. {headson-0.2.4 → headson-0.3.0}/src/serialization/types.rs +2 -0
  18. {headson-0.2.4 → headson-0.3.0}/src/utils/tree_arena.rs +2 -3
  19. headson-0.2.4/PKG-INFO +0 -99
  20. headson-0.2.4/README.md +0 -83
  21. {headson-0.2.4 → headson-0.3.0}/JSONTestSuite/LICENSE +0 -0
  22. {headson-0.2.4 → headson-0.3.0}/JSONTestSuite/README.md +0 -0
  23. {headson-0.2.4 → headson-0.3.0}/LICENSE +0 -0
  24. {headson-0.2.4 → headson-0.3.0}/python/README.md +0 -0
  25. {headson-0.2.4 → headson-0.3.0}/python/headson/__init__.py +0 -0
  26. {headson-0.2.4 → headson-0.3.0}/src/json_ingest/builder.rs +0 -0
  27. {headson-0.2.4 → headson-0.3.0}/src/json_ingest/mod.rs +0 -0
  28. {headson-0.2.4 → headson-0.3.0}/src/lib.rs +0 -0
  29. {headson-0.2.4 → headson-0.3.0}/src/order/mod.rs +0 -0
  30. {headson-0.2.4 → headson-0.3.0}/src/order/scoring.rs +0 -0
  31. {headson-0.2.4 → headson-0.3.0}/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +0 -0
  32. {headson-0.2.4 → headson-0.3.0}/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +0 -0
  33. {headson-0.2.4 → headson-0.3.0}/src/serialization/snapshots/headson__serialization__tests__arena_render_empty.snap +0 -0
  34. {headson-0.2.4 → headson-0.3.0}/src/serialization/snapshots/headson__serialization__tests__arena_render_single.snap +0 -0
  35. {headson-0.2.4 → headson-0.3.0}/src/serialization/templates/json.rs +0 -0
  36. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__order__tests__order_empty_array_order.snap +0 -0
  37. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__order__tests__order_single_string_array_order.snap +0 -0
  38. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__order__tests__pq_empty_array_queue.snap +0 -0
  39. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__order__tests__pq_single_string_array_queue.snap +0 -0
  40. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__queue__tests__pq_empty_array_queue.snap +0 -0
  41. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__queue__tests__pq_single_string_array_queue.snap +0 -0
  42. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__tree__tests__build_tree_empty.snap +0 -0
  43. {headson-0.2.4 → headson-0.3.0}/src/snapshots/headson__tree__tests__build_tree_single.snap +0 -0
  44. {headson-0.2.4 → headson-0.3.0}/src/utils/graph.rs +0 -0
  45. {headson-0.2.4 → headson-0.3.0}/src/utils/json.rs +0 -0
  46. {headson-0.2.4 → headson-0.3.0}/src/utils/mod.rs +0 -0
  47. {headson-0.2.4 → headson-0.3.0}/src/utils/search.rs +0 -0
  48. {headson-0.2.4 → headson-0.3.0}/src/utils/text.rs +0 -0
@@ -2,18 +2,6 @@
2
2
  # It is not intended for manual editing.
3
3
  version = 4
4
4
 
5
- [[package]]
6
- name = "ahash"
7
- version = "0.8.12"
8
- source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
10
- dependencies = [
11
- "cfg-if",
12
- "once_cell",
13
- "version_check",
14
- "zerocopy",
15
- ]
16
-
17
5
  [[package]]
18
6
  name = "allocator-api2"
19
7
  version = "0.2.21"
@@ -115,12 +103,6 @@ dependencies = [
115
103
  "serde",
116
104
  ]
117
105
 
118
- [[package]]
119
- name = "bumpalo"
120
- version = "3.19.0"
121
- source = "registry+https://github.com/rust-lang/crates.io-index"
122
- checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
123
-
124
106
  [[package]]
125
107
  name = "cfg-if"
126
108
  version = "1.0.4"
@@ -194,12 +176,6 @@ dependencies = [
194
176
  "memchr",
195
177
  ]
196
178
 
197
- [[package]]
198
- name = "deunicode"
199
- version = "1.6.2"
200
- source = "registry+https://github.com/rust-lang/crates.io-index"
201
- checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04"
202
-
203
179
  [[package]]
204
180
  name = "difflib"
205
181
  version = "0.4.0"
@@ -218,6 +194,12 @@ version = "1.0.0"
218
194
  source = "registry+https://github.com/rust-lang/crates.io-index"
219
195
  checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
220
196
 
197
+ [[package]]
198
+ name = "equivalent"
199
+ version = "1.0.2"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
202
+
221
203
  [[package]]
222
204
  name = "errno"
223
205
  version = "0.3.14"
@@ -228,16 +210,6 @@ dependencies = [
228
210
  "windows-sys 0.60.2",
229
211
  ]
230
212
 
231
- [[package]]
232
- name = "fake"
233
- version = "2.10.0"
234
- source = "registry+https://github.com/rust-lang/crates.io-index"
235
- checksum = "2d391ba4af7f1d93f01fcf7b2f29e2bc9348e109dfdbf4dcbdc51dfa38dab0b6"
236
- dependencies = [
237
- "deunicode",
238
- "rand",
239
- ]
240
-
241
213
  [[package]]
242
214
  name = "fastrand"
243
215
  version = "2.3.0"
@@ -246,25 +218,18 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
246
218
 
247
219
  [[package]]
248
220
  name = "float-cmp"
249
- version = "0.9.0"
221
+ version = "0.10.0"
250
222
  source = "registry+https://github.com/rust-lang/crates.io-index"
251
- checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
223
+ checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
252
224
  dependencies = [
253
225
  "num-traits",
254
226
  ]
255
227
 
256
228
  [[package]]
257
- name = "getrandom"
258
- version = "0.2.16"
229
+ name = "foldhash"
230
+ version = "0.2.0"
259
231
  source = "registry+https://github.com/rust-lang/crates.io-index"
260
- checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
261
- dependencies = [
262
- "cfg-if",
263
- "js-sys",
264
- "libc",
265
- "wasi",
266
- "wasm-bindgen",
267
- ]
232
+ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
268
233
 
269
234
  [[package]]
270
235
  name = "getrandom"
@@ -280,9 +245,9 @@ dependencies = [
280
245
 
281
246
  [[package]]
282
247
  name = "halfbrown"
283
- version = "0.2.5"
248
+ version = "0.4.0"
284
249
  source = "registry+https://github.com/rust-lang/crates.io-index"
285
- checksum = "8588661a8607108a5ca69cab034063441a0413a0b041c13618a7dd348021ef6f"
250
+ checksum = "0c7ed2f2edad8a14c8186b847909a41fbb9c3eafa44f88bd891114ed5019da09"
286
251
  dependencies = [
287
252
  "hashbrown",
288
253
  "serde",
@@ -290,23 +255,23 @@ dependencies = [
290
255
 
291
256
  [[package]]
292
257
  name = "hashbrown"
293
- version = "0.14.5"
258
+ version = "0.16.0"
294
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
295
- checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
260
+ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
296
261
  dependencies = [
297
- "ahash",
298
262
  "allocator-api2",
263
+ "equivalent",
264
+ "foldhash",
299
265
  ]
300
266
 
301
267
  [[package]]
302
268
  name = "headson"
303
- version = "0.2.4"
269
+ version = "0.3.0"
304
270
  dependencies = [
305
271
  "anyhow",
306
272
  "assert_cmd",
307
273
  "clap",
308
274
  "content_inspector",
309
- "fake",
310
275
  "insta",
311
276
  "rand",
312
277
  "rand_chacha",
@@ -347,73 +312,6 @@ version = "1.0.15"
347
312
  source = "registry+https://github.com/rust-lang/crates.io-index"
348
313
  checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
349
314
 
350
- [[package]]
351
- name = "js-sys"
352
- version = "0.3.81"
353
- source = "registry+https://github.com/rust-lang/crates.io-index"
354
- checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
355
- dependencies = [
356
- "once_cell",
357
- "wasm-bindgen",
358
- ]
359
-
360
- [[package]]
361
- name = "lexical-core"
362
- version = "1.0.6"
363
- source = "registry+https://github.com/rust-lang/crates.io-index"
364
- checksum = "7d8d125a277f807e55a77304455eb7b1cb52f2b18c143b60e766c120bd64a594"
365
- dependencies = [
366
- "lexical-parse-float",
367
- "lexical-parse-integer",
368
- "lexical-util",
369
- "lexical-write-float",
370
- "lexical-write-integer",
371
- ]
372
-
373
- [[package]]
374
- name = "lexical-parse-float"
375
- version = "1.0.6"
376
- source = "registry+https://github.com/rust-lang/crates.io-index"
377
- checksum = "52a9f232fbd6f550bc0137dcb5f99ab674071ac2d690ac69704593cb4abbea56"
378
- dependencies = [
379
- "lexical-parse-integer",
380
- "lexical-util",
381
- ]
382
-
383
- [[package]]
384
- name = "lexical-parse-integer"
385
- version = "1.0.6"
386
- source = "registry+https://github.com/rust-lang/crates.io-index"
387
- checksum = "9a7a039f8fb9c19c996cd7b2fcce303c1b2874fe1aca544edc85c4a5f8489b34"
388
- dependencies = [
389
- "lexical-util",
390
- ]
391
-
392
- [[package]]
393
- name = "lexical-util"
394
- version = "1.0.7"
395
- source = "registry+https://github.com/rust-lang/crates.io-index"
396
- checksum = "2604dd126bb14f13fb5d1bd6a66155079cb9fa655b37f875b3a742c705dbed17"
397
-
398
- [[package]]
399
- name = "lexical-write-float"
400
- version = "1.0.6"
401
- source = "registry+https://github.com/rust-lang/crates.io-index"
402
- checksum = "50c438c87c013188d415fbabbb1dceb44249ab81664efbd31b14ae55dabb6361"
403
- dependencies = [
404
- "lexical-util",
405
- "lexical-write-integer",
406
- ]
407
-
408
- [[package]]
409
- name = "lexical-write-integer"
410
- version = "1.0.6"
411
- source = "registry+https://github.com/rust-lang/crates.io-index"
412
- checksum = "409851a618475d2d5796377cad353802345cba92c867d9fbcde9cf4eac4e14df"
413
- dependencies = [
414
- "lexical-util",
415
- ]
416
-
417
315
  [[package]]
418
316
  name = "libc"
419
317
  version = "0.2.177"
@@ -426,12 +324,6 @@ version = "0.11.0"
426
324
  source = "registry+https://github.com/rust-lang/crates.io-index"
427
325
  checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
428
326
 
429
- [[package]]
430
- name = "log"
431
- version = "0.4.28"
432
- source = "registry+https://github.com/rust-lang/crates.io-index"
433
- checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
434
-
435
327
  [[package]]
436
328
  name = "memchr"
437
329
  version = "2.7.6"
@@ -521,20 +413,19 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
521
413
 
522
414
  [[package]]
523
415
  name = "rand"
524
- version = "0.8.5"
416
+ version = "0.9.2"
525
417
  source = "registry+https://github.com/rust-lang/crates.io-index"
526
- checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
418
+ checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
527
419
  dependencies = [
528
- "libc",
529
420
  "rand_chacha",
530
421
  "rand_core",
531
422
  ]
532
423
 
533
424
  [[package]]
534
425
  name = "rand_chacha"
535
- version = "0.3.1"
426
+ version = "0.9.0"
536
427
  source = "registry+https://github.com/rust-lang/crates.io-index"
537
- checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
428
+ checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
538
429
  dependencies = [
539
430
  "ppv-lite86",
540
431
  "rand_core",
@@ -542,11 +433,11 @@ dependencies = [
542
433
 
543
434
  [[package]]
544
435
  name = "rand_core"
545
- version = "0.6.4"
436
+ version = "0.9.3"
546
437
  source = "registry+https://github.com/rust-lang/crates.io-index"
547
- checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
438
+ checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
548
439
  dependencies = [
549
- "getrandom 0.2.16",
440
+ "getrandom",
550
441
  ]
551
442
 
552
443
  [[package]]
@@ -588,12 +479,6 @@ dependencies = [
588
479
  "windows-sys 0.60.2",
589
480
  ]
590
481
 
591
- [[package]]
592
- name = "rustversion"
593
- version = "1.0.22"
594
- source = "registry+https://github.com/rust-lang/crates.io-index"
595
- checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
596
-
597
482
  [[package]]
598
483
  name = "ryu"
599
484
  version = "1.0.20"
@@ -645,13 +530,11 @@ dependencies = [
645
530
 
646
531
  [[package]]
647
532
  name = "simd-json"
648
- version = "0.13.11"
533
+ version = "0.17.0"
649
534
  source = "registry+https://github.com/rust-lang/crates.io-index"
650
- checksum = "a0228a564470f81724e30996bbc2b171713b37b15254a6440c7e2d5449b95691"
535
+ checksum = "4255126f310d2ba20048db6321c81ab376f6a6735608bf11f0785c41f01f64e3"
651
536
  dependencies = [
652
- "getrandom 0.2.16",
653
537
  "halfbrown",
654
- "lexical-core",
655
538
  "ref-cast",
656
539
  "serde",
657
540
  "serde_json",
@@ -695,7 +578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
695
578
  checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
696
579
  dependencies = [
697
580
  "fastrand",
698
- "getrandom 0.3.4",
581
+ "getrandom",
699
582
  "once_cell",
700
583
  "rustix",
701
584
  "windows-sys 0.60.2",
@@ -739,9 +622,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
739
622
 
740
623
  [[package]]
741
624
  name = "value-trait"
742
- version = "0.8.1"
625
+ version = "0.12.1"
743
626
  source = "registry+https://github.com/rust-lang/crates.io-index"
744
- checksum = "dad8db98c1e677797df21ba03fca7d3bf9bec3ca38db930954e4fe6e1ea27eb4"
627
+ checksum = "8e80f0c733af0720a501b3905d22e2f97662d8eacfe082a75ed7ffb5ab08cb59"
745
628
  dependencies = [
746
629
  "float-cmp",
747
630
  "halfbrown",
@@ -749,12 +632,6 @@ dependencies = [
749
632
  "ryu",
750
633
  ]
751
634
 
752
- [[package]]
753
- name = "version_check"
754
- version = "0.9.5"
755
- source = "registry+https://github.com/rust-lang/crates.io-index"
756
- checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
757
-
758
635
  [[package]]
759
636
  name = "wait-timeout"
760
637
  version = "0.2.1"
@@ -764,12 +641,6 @@ dependencies = [
764
641
  "libc",
765
642
  ]
766
643
 
767
- [[package]]
768
- name = "wasi"
769
- version = "0.11.1+wasi-snapshot-preview1"
770
- source = "registry+https://github.com/rust-lang/crates.io-index"
771
- checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
772
-
773
644
  [[package]]
774
645
  name = "wasip2"
775
646
  version = "1.0.1+wasi-0.2.4"
@@ -779,65 +650,6 @@ dependencies = [
779
650
  "wit-bindgen",
780
651
  ]
781
652
 
782
- [[package]]
783
- name = "wasm-bindgen"
784
- version = "0.2.104"
785
- source = "registry+https://github.com/rust-lang/crates.io-index"
786
- checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
787
- dependencies = [
788
- "cfg-if",
789
- "once_cell",
790
- "rustversion",
791
- "wasm-bindgen-macro",
792
- "wasm-bindgen-shared",
793
- ]
794
-
795
- [[package]]
796
- name = "wasm-bindgen-backend"
797
- version = "0.2.104"
798
- source = "registry+https://github.com/rust-lang/crates.io-index"
799
- checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
800
- dependencies = [
801
- "bumpalo",
802
- "log",
803
- "proc-macro2",
804
- "quote",
805
- "syn",
806
- "wasm-bindgen-shared",
807
- ]
808
-
809
- [[package]]
810
- name = "wasm-bindgen-macro"
811
- version = "0.2.104"
812
- source = "registry+https://github.com/rust-lang/crates.io-index"
813
- checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
814
- dependencies = [
815
- "quote",
816
- "wasm-bindgen-macro-support",
817
- ]
818
-
819
- [[package]]
820
- name = "wasm-bindgen-macro-support"
821
- version = "0.2.104"
822
- source = "registry+https://github.com/rust-lang/crates.io-index"
823
- checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
824
- dependencies = [
825
- "proc-macro2",
826
- "quote",
827
- "syn",
828
- "wasm-bindgen-backend",
829
- "wasm-bindgen-shared",
830
- ]
831
-
832
- [[package]]
833
- name = "wasm-bindgen-shared"
834
- version = "0.2.104"
835
- source = "registry+https://github.com/rust-lang/crates.io-index"
836
- checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
837
- dependencies = [
838
- "unicode-ident",
839
- ]
840
-
841
653
  [[package]]
842
654
  name = "windows-link"
843
655
  version = "0.2.1"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson"
3
- version = "0.2.4"
3
+ version = "0.3.0"
4
4
  edition = "2024"
5
5
  description = "Budget‑constrained JSON preview renderer"
6
6
  readme = "README.md"
@@ -24,16 +24,15 @@ clap = { version = "4.5.49", features = ["derive"] }
24
24
  serde = { version = "1.0.228", features = ["derive"] }
25
25
  serde_json = "1.0.145"
26
26
  unicode-segmentation = "1.12.0"
27
- simd-json = { version = "0.13", features = ["serde_impl"] }
27
+ simd-json = { version = "0.17", features = ["serde_impl"] }
28
28
  content_inspector = "0.2"
29
29
 
30
30
  [dev-dependencies]
31
31
  insta = "1.40.0"
32
32
  assert_cmd = "2"
33
33
  test_each_file = "0.3"
34
- fake = "2"
35
- rand = "0.8"
36
- rand_chacha = "0.3"
34
+ rand = "0.9"
35
+ rand_chacha = "0.9"
37
36
  tempfile = "3"
38
37
 
39
38
  [profile.release]
@@ -94,3 +93,6 @@ implicit_hasher = "deny"
94
93
  uninlined_format_args = "deny"
95
94
  float_cmp = "deny"
96
95
  float_cmp_const = "deny"
96
+
97
+ [lints.rust]
98
+ dead_code = "warn"
headson-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: headson
3
+ Version: 0.3.0
4
+ Classifier: Programming Language :: Python
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Rust
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Dist: pytest>=8 ; extra == 'test'
9
+ Provides-Extra: test
10
+ License-File: LICENSE
11
+ Summary: Budget‑constrained JSON preview renderer (Python bindings)
12
+ Keywords: json,preview,summarize,cli,bindings
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
+
16
+ # headson
17
+
18
+ Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
19
+
20
+ Available as:
21
+ - CLI (see [Usage](#usage))
22
+ - Python library (see [Python Bindings](#python-bindings))
23
+
24
+ ## Install
25
+
26
+ Using Cargo:
27
+
28
+ cargo install headson
29
+
30
+ From source:
31
+
32
+ cargo build --release
33
+ target/release/headson --help
34
+
35
+
36
+ ## Features
37
+
38
+ - *Budgeted output*: specify exactly how much JSON you want to see
39
+ - *Multiple output formats* : `json` (machine‑readable), `pseudo` (human‑friendly), `js` (valid JavaScript, most detailed metadata).
40
+ - *Multiple inputs*: preview many files at once with a shared or per‑file budget.
41
+ - *Fast*: can process gigabyte-scale files in seconds (mostly disk-constrained)
42
+ - *Available as a CLI app and as a Python library*
43
+
44
+ ## Fits into command line workflows
45
+
46
+ If you’re comfortable with tools like `head` and `tail`, use `headson` when you want a quick, structured peek into a JSON file without dumping the entire thing.
47
+
48
+ - `head`/`tail` operate on bytes/lines - their output is not optimized for tree structures
49
+ - `jq` you need to craft filters to preview large JSON files
50
+ - `headson` is like head/tail for trees: zero config but it keeps structure and represents content as much as possible
51
+
52
+ ## Usage
53
+
54
+ headson [FLAGS] [INPUT...]
55
+
56
+ - INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
57
+ - Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
58
+
59
+ Common flags:
60
+
61
+ - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
62
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files). Mutually exclusive with `--budget`.
63
+ - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
64
+ - `-m, --compact`: no indentation, no spaces, no newlines
65
+ - `--no-newline`: single line output
66
+ - `--no-space`: no space after `:` in objects
67
+ - `--indent <STR>`: indentation unit (default: two spaces)
68
+ - `--string-cap <N>`: max graphemes to consider per string (default: 500)
69
+ - `--tail`: prefer the end of arrays when truncating. Strings are unaffected. In `pseudo`/`js` templates the omission marker appears at the start; `json` remains strict JSON with no annotations.
70
+
71
+ Notes:
72
+
73
+ - With multiple input files:
74
+ - JSON template outputs a single JSON object keyed by the input file paths.
75
+ - Pseudo and JS templates render file sections with human-readable headers.
76
+ - Using `--global-budget` may truncate or omit entire files to respect the total budget.
77
+ - The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
78
+ - When passing file paths, directories and binary files are ignored; a notice is printed to stderr for each (e.g., `Ignored binary file: ./path/to/file`). Stdin mode reads the stream as-is.
79
+
80
+ Quick one‑liners:
81
+
82
+ - Peek a big JSON stream (keeps structure):
83
+
84
+ zstdcat huge.json.zst | headson -n 800 -f pseudo
85
+
86
+ - Many files with a fixed overall size:
87
+
88
+ headson -N 1200 -f json logs/*.json
89
+
90
+ - Glance at a file, JavaScript‑style comments for omissions:
91
+
92
+ headson -n 400 -f js data.json
93
+
94
+ Show help:
95
+
96
+ headson --help
97
+
98
+ ## Examples: head vs headson
99
+
100
+ Input:
101
+
102
+ ```json
103
+ {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"meta":{"count":2,"source":"db"}}
104
+ ```
105
+
106
+ Naive cut (can break mid‑token):
107
+
108
+ ```bash
109
+ jq -c . users.json | head -c 80
110
+ # {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
111
+ ```
112
+
113
+ Structured preview with headson (pseudo):
114
+
115
+ ```bash
116
+ headson -n 120 -f pseudo users.json
117
+ # {
118
+ # users: [
119
+ # { id: 1, name: "Ana", roles: [ "admin", … ] },
120
+ # …
121
+ # ]
122
+ # meta: { count: 2, … }
123
+ # }
124
+ ```
125
+
126
+ Machine‑readable preview (json):
127
+
128
+ ```bash
129
+ headson -n 120 -f json users.json
130
+ # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
131
+ ```
132
+
133
+ ## Python Bindings
134
+
135
+ A thin Python extension module is available on PyPI as `headson`.
136
+
137
+ - Install: `pip install headson` (prebuilt wheels for CPython 3.10–3.12 on Linux/macOS/Windows). Older/newer Python versions may build from source if Rust is installed.
138
+ - API:
139
+ - `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, tail: bool = False) -> str`
140
+ - `template`: one of `"json" | "pseudo" | "js"`
141
+ - `character_budget`: maximum output size in characters (default: 500)
142
+ - `tail`: prefer the end of arrays when truncating; strings unaffected. Affects only display templates (`pseudo`/`js`); `json` remains strict.
143
+
144
+ Example:
145
+
146
+ ```python
147
+ import json
148
+ import headson
149
+
150
+ data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
151
+ preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
152
+ print(preview)
153
+
154
+ # Prefer the tail of arrays (annotations show in pseudo/js only)
155
+ print(
156
+ headson.summarize(
157
+ json.dumps(list(range(100))),
158
+ template="pseudo",
159
+ character_budget=80,
160
+ tail=True,
161
+ )
162
+ )
163
+ ```
164
+
165
+ ## License
166
+
167
+ MIT
168
+