adamritter / fastgron

High-performance JSON to GRON (greppable, flattened JSON) converter
MIT License
592 stars 10 forks source link

semicolon output is confused if the JSON contains tabs at the end of a block #20

Closed rjp closed 9 months ago

rjp commented 9 months ago
> fastgron -V
fastgron version 0.6.5
> cat test2.json
{
<TAB>"RecipesUsed": {
<TAB><TAB>"minecraft:glass": 1,
<TAB><TAB>"minecraft:quotes": 2
<TAB>}
}
> fastgron --semicolon < test2.json
json = {};
json.RecipesUsed = {};
json.RecipesUsed["minecraft:glass"] = 1;
json.RecipesUsed["minecraft:quotes"] = 2
        ;
> expand test2.json | fastgron --semicolon
json = {};
json.RecipesUsed = {};
json.RecipesUsed["minecraft:glass"] = 1;
json.RecipesUsed["minecraft:quotes"] = 2;

Seems to be "if there's a tab between the last content and the closing brace, the last semicolon for that block gets kicked a line down".

> cat test4.json
"RecipesUsed": {
"minecraft:quotes": 2
<TAB>},
"moose": 42
}
> fastgron --semicolon < test4.json
json = {};
json.RecipesUsed = {};
json.RecipesUsed["minecraft:quotes"] = 2
        ;
json.moose = 42;
adamritter commented 9 months ago

Thanks, I added tabs as white spaces for tokenization, it will be available when I release v0.7.5 . (I leave this issue open until it is released).

adamritter commented 9 months ago

I released v0.7.5