Is there any way to edit the level.dat as code on MCPE?

There is not any tool for minecraft nbt editing that can run on Android. But there are great tools for PC, like for example the Minecraft Universal Editor.