javascript unmarshalling (not terribly elegant, but it has it's use)