I'm new to coding, can I code a command block into a .json datapack? [closed]

Solution 1:

You can use so called Minecraft Functions an attach them to either the minecraft:tick or minecraft:load Function Tag.

Functions can be run using the /function functionnamehere-command.