GithubHelp home page GithubHelp logo

java-antlr-json-parser's Introduction

Java ANTLR JSON parser

A demo written in Java using ANTLR to parse JSON. I took the specification from json.org. I've added a little twist by adding support for comments. It basically gets ignored by the parser.

Sample input:

// Taken and modified from https://en.wikipedia.org/wiki/JSON
{ // Added comments
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": /* several numbers!*/ [
    {
      "type": "home", // Home sweet home
      "number": "212 555-1234"
    },
    {
      "type": "mobile",
      "number": "123 456-7890"
    } /* seeems to work! */
  ]
}

Sample output:

0 = 
{
    "phoneNumbers" = 
    {
        0 = 
        {
            "type" = "home" java.lang.String
            "number" = "212 555-1234" java.lang.String
        } java.util.HashMap
        1 = 
        {
            "type" = "mobile" java.lang.String
            "number" = "123 456-7890" java.lang.String
        } java.util.HashMap
    } java.util.HashMap
    "address" = 
    {
        "postalCode" = "10021-3100" java.lang.String
        "streetAddress" = "21 2nd Street" java.lang.String
    } java.util.HashMap
    "lastName" = "Smith" java.lang.String
    "firstName" = "John" java.lang.String
    "age" = 25 java.lang.Integer
} java.util.HashMap

java-antlr-json-parser's People

Contributors

hamz-a avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.