How to identified the different functions in value


I have requirement where I have to send code value in json format.
code is

import 'abc';
import 'def';

function test() {

input/output in json:
import: ['abc', 'def'],
body: "console.log('test')"

since codemirror output is always string, currently if i know line number then i can extract the text between range, but the problem this is dynamic code and not static so i dont have line numbers.
Only way to get line number is using some identifier

Sounds like you’ll want to run some kind of parser on the code and analyze its output.