Skip to content

Commit

Permalink
Change to to the org.fogbeam domain, add Ruby symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Fischer committed Aug 19, 2012
1 parent 9bcdf20 commit ae15086
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ None of the following is legitimate JSON code, yet you will find it in the wild.

* *Bareword Keys* - Yup, that's invalid JSON. For reals.

* *Ruby Symbols* - Because they're pervasive bugs across the internet.

* *Large Numerical Value Support* - Not technically a fault, but most libraries parse integers and decimals using doubles or longs, which can be a problem if you have large values in your JSON. This library uses `BigDecimal` and `BigInteger` by default for more accurate parsing. You can shift to using double and long values by setting the `parser.nativeNumbers` property, but if you are thinking about setting that flag for performance reasons, you're almost certainly doing it wrong.

Usage
Expand All @@ -21,7 +23,7 @@ Usage
Here's a minimal example:

```java
import com.smokejumperit.json.parser.JSONParser
import org.fogbeam.json.parser.JSONParser;

public class Foo {
public static void main(String[] args) {
Expand All @@ -30,7 +32,7 @@ public class Foo {
}
```

Also available on the `JSONParser` type:
Also available on the `JSONParser` class:

* `InputStream` and `Reader` constructors - For your consuming convenience
* `parseObject()` - Parses a JSON object into a `LinkedHashMap`
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ version = "0.0.1.2"
apply plugin:'groovy'
apply plugin:com.smokejumperit.gradle.compiler.JavaccPlugin

/*
apply from:'http://gradle.smokejumperit.com/sjit_repo.gradle'
apply from:'http://gradle.smokejumperit.com/github-dev.gradle'
apply from:'http://gradle.smokejumperit.com/all-jars.gradle'
*/

buildscript {
repositories {
Expand All @@ -21,7 +23,7 @@ buildscript {
mavenRepo url:'http://repo.smokejumperit.com'
}
dependencies {
classpath 'org.fogbeam.gradle:gradle-javacc-plugin:[0.0.5,1)'
classpath 'RobertFischer:gradle-javacc-plugin:0.0.5.4'
}
}

Expand Down
25 changes: 14 additions & 11 deletions src/main/javacc/com/smokejumperit/json/parser/JSONParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ options {

PARSER_BEGIN(JSONParser)

package com.smokejumperit.json.parser;
package org.fogbeam.json.parser;

import java.io.*;
import java.util.*;
Expand Down Expand Up @@ -326,36 +326,39 @@ String string() : {
String rubySymbol(): {
}{
<RUBY_SYMBOL>
{ return t.image.substring(1); }
{ return token.image.substring(1); }
}

String doubleQuoteString() : {
Token t;
}{
(
<STRING_DOUBLE_EMPTY>
{ return ""; }
) | (
t = <STRING_DOUBLE_NONEMPTY>
{ return t.image.substring(1, t.image.length()-1); }
<STRING_DOUBLE_NONEMPTY>
{
String image = token.image;
return image.substring(1, image.length()-1);
}
)
}

String singleQuoteString() : {
Token t;
}{
(
<STRING_SINGLE_EMPTY>
{ return ""; }
) | (
t = <STRING_SINGLE_NONEMPTY>
{ return t.image.substring(1, t.image.length()-1); }
<STRING_SINGLE_NONEMPTY>
{
String image = token.image;
return image.substring(1, image.length()-1);
}
)
}

String symbol() : {
Token t;
}{
t = <SYMBOL>
{ return t.image; }
<SYMBOL>
{ return token.image; }
}

0 comments on commit ae15086

Please sign in to comment.