<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Siddhant Zawar on Medium]]></title>
        <description><![CDATA[Stories by Siddhant Zawar on Medium]]></description>
        <link>https://medium.com/@zsiddhant?source=rss-584236bdc3c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bzrjBsQlNfOPEqUmuNdi8A.jpeg</url>
            <title>Stories by Siddhant Zawar on Medium</title>
            <link>https://medium.com/@zsiddhant?source=rss-584236bdc3c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:09:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zsiddhant/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building your own JSON Parser]]></title>
            <link>https://towardsdev.com/building-your-own-json-parser-67f5ac46c1af?source=rss-584236bdc3c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/67f5ac46c1af</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[validator]]></category>
            <category><![CDATA[parser]]></category>
            <dc:creator><![CDATA[Siddhant Zawar]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 16:47:24 GMT</pubDate>
            <atom:updated>2024-01-01T11:45:42.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEd8p7hMn0vrVQCs3EdMCQ.png" /></figure><p>As I embarked on a holiday coding adventure, my quest to build something meaningful, I stumbled on <a href="https://codingchallenges.fyi/challenges/challenge-json-parser.">https://codingchallenges.fyi/<br>challenges/challenge-json-parser.</a> Coinciding with this, my long-standing curiosity about Go programming found the perfect opportunity to materialize. In this blog post, join me on a journey as I share a detailed walkthrough of constructing a JSON Parser.</p><h3>What is JSON?</h3><p><strong>JSON</strong> (JavaScript Object Notation) is a lightweight data interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.</p><p>Building a parser is effectively building your compiler which can understand input string, pre-process, validate against the JSON Grammar/Rules and emit out a result if it is valid or not. We will use Lexical Analysis and Parser Approach to build this.</p><h3>What is Lexical Analysis?</h3><p>It is the first phase of any compiler, where it reads the input string byte by byte and converts it into a sequence of tokens.</p><p>For example, let&#39;s take a simple statement from C-language.</p><pre>int a = 10;</pre><p>Here the tokens generated will be int a = 10 ;</p><p>Lexical Analyser consists of 4 stages :</p><ol><li><strong>Pre-Processing:</strong> This stage is to remove all the unwanted characters like space, new lines, and comments from the input.</li><li><strong>Tokenisation:</strong> This stage breaks the sequence of characters into different sets of tokens by matching the input characters against a set of patterns or regular expressions.</li><li><strong>Token Classification:</strong> At this stage, we will classify the generated token into different categories like Keyword, Condition Statement, etc.</li><li><strong>Output Generation:</strong> This stage will finally emit out the sequence of tokens with their categories, which will then be consumed by the Parser to validate against the Language grammar.</li></ol><p>Let&#39;s first define the basic units of token of JSON :</p><pre>OPEN_BRACES   Type = &quot;{&quot;<br>	CLOSED_BRACES Type = &quot;}&quot;<br>	LEFT_BRACKET  Type = &quot;[&quot;<br>	RIGHT_BRACKET Type = &quot;]&quot;<br>	COMMA         Type = &quot;,&quot;<br>	COLON         Type = &quot;:&quot;<br>	STRING        Type = &quot;STRING&quot;<br>	NUMBER        Type = &quot;NUMBER&quot;<br>	BOOLEAN       Type = &quot;BOOLEAN&quot;<br>	NULL          Type = &quot;NULL&quot;<br>	ILLEGAL       Type = &quot;ILLEGAL&quot;</pre><p>Also, the data structure of the token will be in this format :</p><pre>type Token struct {<br>	Type  Type<br>	Value string<br>	Line  int<br>	Start int<br>	End   int<br>}</pre><p>Process of Pre-Processing and Tokenisation: Here we will read the input string character by character ignore the whitespace and call createToken function.</p><pre>func Tokenization(input string) []token.Token {<br> lines := strings.Split(input, &quot;\\n&quot;)<br> var tokens []token.Token<br> for i := 0; i &lt; len(lines); i++ {<br>  line := lines[i]<br>  charArray := strings.Split(line, &quot;&quot;)<br>  for j := 0; j &lt; len(charArray); {<br>   if isWhiteSpace(charArray[j]) {<br>    j++<br>   } else {<br>    var t = createToken(line, j, i)<br>    j = t.End<br>    tokens = append(tokens, t)<br>   }<br>  }<br> }<br> return tokens<br>}</pre><p>Token Creation and Classification: Here each character is classified into the basic unit we defined above.</p><pre>func createToken(input string, pos int, line int) token.Token {<br> var t token.Token<br><br> switch input[pos] {<br> case &#39;{&#39;:<br>  t = newToken(token.OPEN_BRACES, &quot;{&quot;, line, pos, pos+1)<br> case &#39;}&#39;:<br>  t = newToken(token.CLOSED_BRACES, &quot;}&quot;, line, pos, pos+1)<br> case &#39;[&#39;:<br>  t = newToken(token.LEFT_BRACKET, &quot;[&quot;, line, pos, pos+1)<br> case &#39;]&#39;:<br>  t = newToken(token.RIGHT_BRACKET, &quot;]&quot;, line, pos, pos+1)<br> case &#39;:&#39;:<br>  t = newToken(token.COLON, &quot;:&quot;, line, pos, pos+1)<br> case &#39;,&#39;:<br>  t = newToken(token.COMMA, &quot;,&quot;, line, pos, pos+1)<br> case &#39;&quot;&#39;:<br>  str, end := parseString(input, pos)<br>  t = newToken(token.STRING, str, line, pos, end)<br> default:<br>  if isNumber(rune(input[pos])) {<br>   num, end := parseNumber(input, pos)<br>   return newToken(token.NUMBER, num, line, pos, end)<br>  } else if isLetter(rune(input[pos])) {<br>   letter, end := parseLetter(input, pos)<br>   if letter == &quot;true&quot; {<br>    return newToken(token.NUMBER, &quot;true&quot;, line, pos, end)<br>   } else if letter == &quot;false&quot; {<br>    return newToken(token.BOOLEAN, &quot;false&quot;, line, pos, end)<br>   } else if letter == &quot;null&quot; {<br>    return newToken(token.NULL, &quot;null&quot;, line, pos, end)<br>   }<br>  }<br>  t = newToken(token.ILLEGAL, string(input[pos]), line, pos, pos+1)<br><br> }<br> return t<br>}</pre><p>Now that we have the sequence of Tokens correctly categorised, Let&#39;s understand JSON Language grammar from <a href="https://www.json.org/json-en.html">https://www.json.org/json-en.html</a></p><p>JSON Object Grammar :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ByX1YEx_eWvstx3ov-iwgg.png" /></figure><p>JSON Array Grammar :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPkDcIq896Kt_t8lCIoOUA.png" /></figure><p>Value Grammar :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uvv9tNM54LA-GhdJLvxTig.png" /></figure><p>Let&#39;s implement the same logic in our Parser :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*pTdxXrhlpQGEWwe9X6l9tA.gif" /></figure><pre>func ParseJSON(tokens []token.Token) {<br>	valid := true<br>	for i := 0; i &lt; len(tokens) &amp;&amp; valid == true; i++ {<br>		switch tokens[i].Type {<br>		case token.OPEN_BRACES:<br>			valid, i = objectParser(tokens, i+1)<br>		case token.LEFT_BRACKET:<br>			valid, i = arrayParser(tokens, i+1)<br>		case token.COMMA:<br>			i++<br>		default:<br>			valid = false<br>			invalidJSONFormat(tokens[i])<br>		}<br>	}<br>	if valid == true {<br>		fmt.Println(&quot;JSON is Valid&quot;)<br>	}<br>}</pre><p>You can find the complete code here: <a href="https://github.com/zsiddhant/GoJsonParser">https://github.com/zsiddhant/GoJsonParser</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67f5ac46c1af" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/building-your-own-json-parser-67f5ac46c1af">Building your own JSON Parser</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up an alarm in AWS cloudwatch]]></title>
            <link>https://zsiddhant.medium.com/setting-up-an-alarm-in-aws-cloudwatch-207bf1cc1c65?source=rss-584236bdc3c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/207bf1cc1c65</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[cloudwatch-logs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Siddhant Zawar]]></dc:creator>
            <pubDate>Tue, 27 Oct 2020 18:16:41 GMT</pubDate>
            <atom:updated>2020-10-27T18:16:41.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*3BAC2llwtKNf0K9zOWkf4w.png" /></figure><p>Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications you run on AWS. You can use Amazon CloudWatch to collect and track metrics, collect and monitor log files, set alarms, and automatically react to changes in your AWS resources. Amazon CloudWatch can monitor AWS resources such as Amazon EC2 instances, Amazon DynamoDB tables, and Amazon RDS DB instances, as well as custom metrics generated by your applications and services, and any log files your applications generate. You can use these insights to react and keep your application running smoothly.</p><p>By default, it monitors host-level metrics: CPU, Network, Disk, Status Checks. Rest all monitoring needs to be configured.</p><p>Today we will see how to create a metric and set alarm over it. The example which we will be looking at is to trigger an alarm if there X no. of exceptions in our log files in the Y time frame.</p><ul><li>First, select the log group, and click on <strong>Create Metric Filter</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_EXKjqJyE5qVCybDzag8kA.png" /></figure><ul><li>Then fill in the pattern which you want to track, let&#39;s say I want to track all the exceptions coming in the log.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7fpzNgutYn1cQh8m3JvPA.png" /></figure><ul><li>Fill out the rest of the details like name, and value per matched event.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JT9IB9KyojnZrqof9H0Xw.png" /></figure><ul><li>Once you are done, you will get an option to create an alarm on the metric defined.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDvAA7TnbfTv7y9rzY6MiQ.png" /></figure><ul><li>Here you can define the statistics through which you would want to receive a trigger(alarm). Let&#39;s say I want a trigger if there are more than 10 exceptions in 5 minutes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qX8bJeZp5hSM3j25FtPsdA.png" /></figure><ul><li>Just below you will find the additional configuration, where you can also define no of breaching events post that you would want a trigger of the alarm. Also, there is one additional part where you can define what does missing data means to your whether it qualifies for alarm or not. In this case, if we don&#39;t find any exception event we will teat it as “Not breaching the threshold”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14WMdbPzajAunlsOqBlAgA.png" /></figure><ul><li>Post this you need to select the SNS topic or email list to which this event will be triggered.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMPb7rqxrCreBTC3VvF2wQ.png" /></figure><ul><li>Fill out the rest of the details in step 3, stating the alarm name and description. Preview all the details in step 4 and click on create alarm.</li></ul><p>The alarm can not only trigger to send out a notification event but also help in auto-scaling of ec2 instances if you were tracking Cpu utilization and would want to scale your stack if it reached a certain threshold.</p><p>There are no upfront fees for the cloudwatch you pay for what you use. Pricing is calculated on different levels like log size, metrics, alarms, dashboards, etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=207bf1cc1c65" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>