Replaced goto structure (since not supported in XC)
Further porting of JSMN