The reason you run into a problem is probably that the program you attempt to resolve uses the parent pointer, so you get a T_FUNCTION rather than a T_PROGRAM. For what purpose do you need the program pointer? For some purposes, program.c:program_from_svalue() may return something you can use. You may also want to have a look at object.c:parent_clone_object().
I added a print_svalue for debugging and is gives me the name of the program i was looking up. Printing its type gives me type 4 (T_FUNCTION). Now I tried using program_from_svalue but it gives me the following error:
Parent lost, cannot clone program. /usr/lib/pike/modules/Public.pmod/Parser.pmod/JSON2.pmod/module.pmod:0: Public.Parser.JSON2->parse("Parent lost, cannot clone program.\n")
Is that because the parse function is not running in object context?
Correct, as I said above, you probably want to use parent_clone_object() (or just call the svalue directly). Do you actually need the program pointer for something?