Well I have a perl script that formats a json by leaving it in this format:
{"nome1":"123","nome2":"123","nome3":"123",}
But I want only the last occurrence to be just the key without the comma before. like this:
{"nome1":"123","nome2":"123","nome3":"123"}
Code:
open(FILEHANDLE, '<', 'prices.json');
my $file = <FILEHANDLE>;
close(FILEHANDLE);
open(salvar,'>>','730.json');
print salvar "{";
while($file =~ m/"name":"(.*?)","price":(.*?),/ig) {
my $name = $1;
my $price = $2 / 100;
print $name.":".$price."\n";
print salvar '"'.$name.'":"'.$price.'"'.",\n";
}
print salvar "}";