Answer the question
In order to leave comments, you need to log in
How can I make the bot record users as I need?
I have a level system on the server and the bot writes each new user to the profile.json file, but it writes them to the porridge, for example:
{"id1":{"coins":0,"warns":0,"xp" :0,"lvl":0},"id2":{"coins":0,"warns":0,"xp":0,"lvl":0}}.
Here, but I need him to write them down in a column, like this:
{"id1":{"coins":0,"warns":0,"xp":0,"lvl":0},
{"id2 ":{"coins":0,"warns":0,"xp":0,"lvl":0}.
For I am very confused in this all sorting out who-where.
Answer the question
In order to leave comments, you need to log in
Well, as it were, there is not a jamb of a bot, and not a jamb of a language. This is how the JSON standard was designed. You can apply formatting to the file (where 4 is the number of spaces in the tab level). You can use another data format, for example - CSV. You can connect a database, some kind of SQLite . Of course, you can write your bike:JSON.stringify(data, null, 4)
const toJSON = data => {
if (Array.isArray(data)) {
const prepared = data.map(value => JSON.stringify(value));
return `[\n${prepared.join(',\n')}\n]`;
} else {
const prepared = Object.entries(data).map(([key, value]) => (
`${JSON.stringify(key)}: ${JSON.stringify(value)}`
));
return `{\n${prepared.join(',\n')}\n}`;
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question