mirror of
https://github.com/therootcompany/golib.git
synced 2026-11-04 15:05:00 +00:00
Rewrote looksLikeMap from 6 layered heuristics down to 3 simple rules: 1. All numeric keys → map (certain) 2. Any key composed of words → struct (certain) 3. Everything else → map (safe default) The asymmetry is deliberate: a map misidentified as a struct explodes into hundreds of fields, while a struct misidentified as a map is compact and easy to fix. Word detection splits keys on _ and camelCase, checks segments for pronounceability (vowel/consonant rhythm). Short words (id, at, on) only count when paired with a strong 3+ char word. Also adds raw path type naming with Item suffix for collections (FriendsItem instead of Friend), real API test fixtures from PokeAPI and SWAPI, and UUID-based test data replacing synthetic abc123 keys.
Test Data Sources
These JSON fixtures are used for integration testing of the jsontypes package.
- pokemon-pikachu.json — Single Pokemon record from PokeAPI (BSD 3-Clause). Pokemon is © Nintendo/The Pokemon Company.
- swapi-luke.json — Luke Skywalker from SWAPI (BSD 3-Clause). Star Wars is © Lucasfilm Ltd.
- swapi-planets.json — First page of planets from SWAPI (BSD 3-Clause). Star Wars is © Lucasfilm Ltd.