private JsonScanner GetTokenizer() { MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms); sw.Write(textJson.Text); sw.Flush(); ms.Position = 0; JsonScanner tokenizer = new JsonScanner(); tokenizer.SetInput(new StreamReader(ms)); return(tokenizer); }
private void buttonParse_Click(object sender, EventArgs e) { JsonScanner scanner = new JsonScanner(); scanner.SetInput(textJson.Text); JsonParser parser = new JsonParser(scanner); parser.ThrowError = false; bool ret = parser.ParseObject(); if (ret) { Debug.WriteLine("Parse OK"); } else { Debug.WriteLine("Parse error: MSG={0} TOKEN={1}", parser.ParseErrorMessage, parser.ParseErrorToken); } }
private void buttonScan_Click(object sender, EventArgs e) { JsonScanner scanner = new JsonScanner(); scanner.SetInput(textJson.Text); Debug.WriteLine("---------------------------"); while (true) { JsonScannerToken token = scanner.GetToken(); Debug.WriteLine("Token: {0} (pos {1}, {2})", token, token.NumeroLinha, token.NumeroColuna); if (token.Type == eTokenType.Erro) { Debug.WriteLine("SCAN Error: {0}", token.Mensagem, null); break; } if (token.Type == eTokenType.Eof) { break; } } }