Modified main.c to return json and gnid