You need to build a string of all objects and their positions in the level, then export this string. And you need a code which will do this in reverse - decode the string and restore objects and positions from it.
How you do this really depends on your game and the complexity of levels.
If your level is just one tilemap, you can simply export all tiles in JSON. If your level consists of many different sprites, you can put their names, coordinates, sizes, angle and other properties into an array, and then save this array as JSON.
If your game is grid based, you can invent some creative and compact way to save it, for example see how the chess board is saved in FEN format:
https://www.dailychess.com/chess/chess-fen-viewer.php
Thanks, I'll try to figure it out!