fixed json parsing;
init curl at the beginning;
removed useless cast;