Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when parsing empty string #7

Open
GoogleCodeExporter opened this issue Jul 11, 2015 · 2 comments
Open

Exception when parsing empty string #7

GoogleCodeExporter opened this issue Jul 11, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. create the java Class
package experiment;
import java.util.Map;
import com.json.parsers.JSONParser;
import com.json.parsers.JsonParserFactory;

public class Dummy {
    public static void main(String[] args) {

        JsonParserFactory factory=JsonParserFactory.getInstance();
        JSONParser parser = factory.newJsonParser();
        String strJSONtoParse = "{\"id\":\"[EMPTY]\",\"AN_Response\":\"\"}";
        System.out.println("Parsing of : " + strJSONtoParse);
        Map mapModel = parser.parseJson(strJSONtoParse);
        System.out.println("Empty String : '" + mapModel.get("AN_Response")+"'");
    }
}

2.  Run the Class (execute "main()")

What is the expected output? What do you see instead?
>>expected output console:
Parsing of : {"id":"[EMPTY]","AN_Response":""}
Empty String : ''
>> what I see
Parsing of : {"id":"[EMPTY]","AN_Response":""}
Exception in thread "main" com.json.exceptions.JSONParsingException: 
@Key-Heirarchy::root/   @Key::AN_Response   Value is expected but found 
empty...@Position::32
    at com.json.utils.JSONUtility.handleFailure(JSONUtility.java:124)
    at com.json.parsers.JSONParser.stringLiteralTemplate(JSONParser.java:580)
    at com.json.parsers.JSONParser.nonValidatingValueTemplate(JSONParser.java:698)
    at com.json.parsers.JSONParser.parseValue(JSONParser.java:377)
    at com.json.parsers.JSONParser.parseKeysValues(JSONParser.java:254)
    at com.json.parsers.JSONParser.parseJsonBody(JSONParser.java:232)
    at com.json.parsers.JSONParser.parseJsonBlock(JSONParser.java:212)
    at com.json.parsers.JSONParser.parseJson(JSONParser.java:139)
    at experiment.Dummy.main(Dummy.java:20)



What version of the product are you using? On what operating system?
OS : OpsenSUSE linux 12.3 x86_64
jdk : 1.7.0_40
Eclipse : Luna build id: 20131113-1838
quickjson : 1.0.2.3

Please provide any additional information below.
/

Original issue reported on code.google.com by [email protected] on 17 Dec 2013 at 8:48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant