[mod] refactor for lisibility
[fix] uniformise output handling for the json api part