GithubHelp home page GithubHelp logo

json-smart's Introduction

json-smart's People

Contributors

urielch avatar

Watchers

James Cloos avatar  avatar

json-smart's Issues

Trailing commas are tolerated in strict mode

What steps will reproduce the problem?

// Note: There are two extra commas, one in the array between the int values 
and one in the object where a next property is expected
JSONValue.parseStrict("{\"array\":[1,2,3,4,444,],}");


What is the expected output? What do you see instead?
In strict mode I would expect trailing commas with no subsequent properties to 
throw an exception.

What version of the product are you using? On what operating system?
Java 1.6, Windows 7, json-smart from trunk as of June 13th 2011

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Jun 2011 at 12:58

JSONArray is deserialized to ArryList

I use your excellent library in Android project. I run into issue where if I 
try to pass JSONArray to the Activity by doing Intent.putExtra(String key, 
Serializable array) when I try to retrieve that array doing 
Intent.getSeriaizableExtra(key, null) array is converted to the plain 
ArrayList. Not only that but all the nested JSONObjects are converted to 
HashMaps. Currently I go around this by dumping content of JSONArray to String 
and then recreating it. However that is quite memory intensive especially for 
larger data sets. 
Anything you would recommend?

Regards,

Bo Stone

Original issue reported on code.google.com by [email protected] on 12 Nov 2011 at 7:27

Is the project dead ?

Hi,

Sorry this is not really an issue, but I didn't find a better communication 
vector.
I'm searching for a good lightweight json library and this one seem perfect for 
my needs. But one thing worry me, no update since Aug 2013.

Is a new update planned or the project is dead/dormant ?

In all cases, thanks you for this project !

Original issue reported on code.google.com by [email protected] on 3 Jun 2014 at 9:12

Invalid JSON is getting parsed instead of throwing exception

What steps will reproduce the problem?
1. JsonValue.parseStrict() method
2. pass string "{ \"param1\": \"value1\", \"param2\": \"value2\" }\\\\\\" 
3. It should throw parser exception

What is the expected output? What do you see instead?
ParseException should be thrown but instead getting valid object

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 17 Jul 2014 at 6:16

Tests do not allow correct variant forms (unescaped '/', unicode chars)

Although Wiki page correctly mentions that there are multiple acceptable forms 
for many things (many escapes are optional; and there are both named and 
unicode escapes), tests do not seem to allow for all variants.
For example, it looks like outputting slash ('/') as is results in a fail, 
whereas escaped variant ('\/') is accepted.

Original issue reported on code.google.com by [email protected] on 21 May 2011 at 10:39

json-smart JAR does not export the writer package for OSGi

I am using the json-smart 2.1.0 JAR with another project called json-path. 

json-path uses the writer functionality of json-smart, but the OSGi bundle do 
not export this package so the OSGi framework fails

org.osgi.framework.BundleException: Unresolved constraint in bundle 
org.apache.camel.camel-jsonpath [95]: Unable to resolve 95.0: missing 
requirement [95.0] osgi.wiring.package; 
(&(osgi.wiring.package=com.jayway.jsonpath)(version>=1.2.0)(!(version>=2.0.0))) 
[caused by: Unable to resolve 88.0: missing requirement [88.0] 
osgi.wiring.package; (osgi.wiring.package=net.minidev.json.writer)]


See ticket: https://code.google.com/p/json-path/issues/detail?id=66


The MANIFEST.MF has today

Export-Package: net.minidev.json;uses:="net.minidev.json.annotate,net.mi
 nidev.asm,net.minidev.json.parser";version="2.1.0",net.minidev.json.ann
 otate;version="2.1.0",net.minidev.json.parser;uses:="net.minidev.json";
 version="2.1.0"


Notice that net.minidev.json.writer package is not exported. That package needs 
to be added.


Original issue reported on code.google.com by [email protected] on 30 Jan 2015 at 5:34

ParseException provides no message

Hi again,

As with JSON Simple I found out that here the parse error message issue exists 
too.

Here is the original issue:

http://code.google.com/p/json-simple/issues/detail?id=45


Vladimir

Original issue reported on code.google.com by [email protected] on 27 May 2011 at 9:22

java.lang.SecurityException: Prohibited package name: java.lang

See the attached file for a JUnit test that reproduces the bug. 

Here's the StackTrace:
java.lang.SecurityException: Prohibited package name: java.lang
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:649)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:785)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at net.minidev.asm.DynamicClassLoader.defineClass(DynamicClassLoader.java:86)
    at net.minidev.asm.BeansAccessBuilder.bulid(BeansAccessBuilder.java:313)
    at net.minidev.asm.BeansAccess.get(BeansAccess.java:105)
    at net.minidev.json.mapper.BeansMapper$Bean.<init>(BeansMapper.java:40)
    at net.minidev.json.mapper.Mapper.getMapper(Mapper.java:105)
    at net.minidev.json.mapper.Mapper.getMapper(Mapper.java:75)
    at net.minidev.json.mapper.BeansMapper$Bean.startObject(BeansMapper.java:83)
    at net.minidev.json.parser.JSONParserBase.readMain(JSONParserBase.java:387)
    at net.minidev.json.parser.JSONParserBase.readObject(JSONParserBase.java:530)
    at net.minidev.json.parser.JSONParserBase.readFirst(JSONParserBase.java:285)
    at net.minidev.json.parser.JSONParserBase.parse(JSONParserBase.java:150)
    at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:57)
    at net.minidev.json.parser.JSONParser.parse(JSONParser.java:253)
    at net.minidev.json.JSONValue.parse(JSONValue.java:210)
    at JsonSmartTest.doTest(JsonSmartTest.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I suppose you're not type-guessing. I would expect "obj" to be recognized as a 
json hash and so be decoded as a generic Map<String, Object>

Original issue reported on code.google.com by [email protected] on 21 Jan 2014 at 10:52

Attachments:

Style escape/protect is broken (incorrect bit logic)

The following code exists in both v1 and v2 of JSONStyle.java:

    _protectKeys = (FLAG & FLAG_PROTECT_KEYS) == 0;
    _protectValues = (FLAG & FLAG_PROTECT_VALUES) == 0;
    _protect4Web = (FLAG & FLAG_PROTECT_4WEB) == 0;

Presumably this is meant to check that FLAG is set, and that (e.g.) it contains 
the FLAG_PROTECT_4WEB flag.  Except that by comparing to zero, you're doing the 
opposite of what you want.  You should be comparing to "> 0" not "== 0" (like 
you do a few lines below that with the FLAG_AGRESSIVE check).

Anyway, this has the unfortunate effect of making it impossible to use any of 
the "protect" features.

Attached diff should fix the issue for v1.

Original issue reported on code.google.com by [email protected] on 22 Mar 2012 at 10:56

Attachments:

ParseException contains misspelling ("secance")

ParseException 
(https://code.google.com/p/json-smart/source/browse/json-smart/src/main/java/net
/minidev/json/parser/ParseException.java?repo=v1&r=28a655898c1e66357c89697078b84
3bf87249bcb) contains the misspelled word "secance". Likely fix is "sequence".


Original issue reported on code.google.com by [email protected] on 11 Nov 2013 at 6:00

net.minidev.json.parser.ParseException should NOToverride toString() but getMessage()

Right now the ParseException's 'toString' method is overridden. Which
leaves the get[Localized]Message methods returning NULL. 

This bug is very annoying because it breaks standard error-handling code,
due to:

1. It breaks the typical exception.toString() implementation not to report its 
name first
(this is the most disturbing).

2. The exception does not have an exception-message at all.



Obviously the bug was copied from json-simple, see respective issue-5 there.


What steps will reproduce the problem?
1. Capture any net.minidev.json.parser.ParseException.
2. The 'getMessage' or 'getLocalizedMessage' return NULL (although there is a 
message returned by toString)
4. The toString() does not report exception-name.

VERSION: 1.1.1, module: v1 (have not checked v2)

FIX

---
Please, 
a) move the code from ParseException.toString() to ParseException.getMessage(),
and 
b) stop overridding toString() method.

Original issue reported on code.google.com by [email protected] on 11 Apr 2013 at 6:29

cannot output the inherit properties from super class?

What steps will reproduce the problem?
1. defined super class with protected properties.
2. defined sub class inherited from  super
3. output the sub info . But it doesnot any inherited properties.

What is the expected output? What do you see instead?
I wanna see the protected properties in sub class.

What version of the product are you using? On what operating system?
json-smart  1.0.9-1
win7 and centos5 . x64

Please provide any additional information below.
contact by gmail . I need eagerly. 
Thank you!

Original issue reported on code.google.com by [email protected] on 18 Apr 2012 at 10:00

Clones of json-smart are empty

I cloned json-smart but the clone only had these these files:

 /v1
/v2
/wiki
readme.txt


The dirs are empty. I looked through the other clones and found a few that 
looked messed up like mine.

any ideas?

Original issue reported on code.google.com by [email protected] on 15 May 2013 at 9:57

JSONObject should use LinkedHashMap instead of HashMap

I'm using this in conjunction with JsonPath and I have been debugging my 
problem for a while.  The issue is that the order I get the keys back changes 
between generation of the JSON and parsing of the JSON as the JSONObject is 
backed by a HashMap.  Hence if I build a structure, serialize and deserialize, 
I don't actually have the same structure.

Original issue reported on code.google.com by [email protected] on 1 Mar 2013 at 12:32

JDK<1.5 support

Hi,

   your project is really interesting as JSON-SIMPLE is quite stagnant but I must use JDK 1.4.2... and json-smart looks like it is not compatible. Am I wrong? Any plan to support older JVM?

Thanks
Bye
Piero

Original issue reported on code.google.com by [email protected] on 10 Aug 2011 at 2:06

Enhance Generic Types

Hi,

it would be really nice to improve the generics of JSONArray static methods.
A fix "List<Object>" is very unflexible at this point, and leads always to 
casts.
List<? extends Object> would be a much better Api.
See for further details:
http://en.wikipedia.org/wiki/Wildcard_%28Java%29#Example:_Lists

Regards

Original issue reported on code.google.com by [email protected] on 12 Jul 2011 at 7:06

JSONStringParser allows trailing junk

What steps will reproduce the problem?
1. Create a JSONParser with any mode.
2. jsonParser.parse("[1]1");
3. No exceptions are thrown.

What is the expected output? What do you see instead?

Some exception indicating that there are trailing characters.

What version of the product are you using? On what operating system?

1.0.9-1

Please provide any additional information below.

In 
http://code.google.com/p/json-smart/source/browse/1.0.X/json-smart/src/main/java
/net/minidev/json/parser/JSONStreamParser.java

readMain() simply does "return readArray();" for example. It would need to do 
the readArray() but then check for additional non-whitespace and throw an error 
if it is found.

Original issue reported on code.google.com by [email protected] on 7 Dec 2011 at 4:29

'/' is being escaped. why?

The source code to reproduce a problem:
    @Test
    public void testJSON() {
        JSONObject object = new JSONObject();
        object.put("///////", "//////");
        System.out.println(object.toJSONString());
    }

Expected output:
{"\/\/\/\/\/\/\/":"\/\/\/\/\/\/"}
{"///////":"//////"}

I tried both 1.0.9 and 2.0.0-alpha1 versions, and the json-smart always escaped 
the "/" symbol. Isn't this pointless? Thanks.

Original issue reported on code.google.com by [email protected] on 19 Sep 2011 at 6:46

javabean JSR , boolean property isnot right.

What steps will reproduce the problem?
1. JavaBean  , boolean isPopping 
2. json-smart outputs
3.

What is the expected output? What do you see instead?
Just like Eclipse IDE generates codes.
    public boolean isPopping() {
        return isPopping;
    }



What version of the product are you using? On what operating system?
json-smart-1.1.1

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 5 Jun 2012 at 8:24

Leading zeroes should not be permitted when using parseStrict

What steps will reproduce the problem?

JSONValue.parseStrict({"name":0000123});

What is the expected output? What do you see instead?

The RFC 4627 specifies that leading zeroes are not permitted. (2.4 - Leading 
zeros are not allowed.)  It should result into an exception.

What version of the product are you using? On what operating system?
Windows 7, Java 1.6

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Jun 2011 at 12:30

BigDecimal serialization is not supported

What steps will reproduce the problem?
1. BigDecimal serialization is not supported
2.
3.

What is the expected output? What do you see instead?
blank output

What version of the product are you using? On what operating system?
1.3.1

Please provide any additional information below.
BigDecimal.class should be added to registerWriter as part of Number writer 
registration in init function of JsonWriter class.

Original issue reported on code.google.com by [email protected] on 22 Oct 2014 at 8:55

improve JSONValue.toJSONString(new MyClass()) serialization of an object

Hello,

will be nice to be able to configure some options for this feature ala gson.

on gson lib, you are able to 
1) write custom serializer (can be done imps JSONAware so its ok)
2) write custom exclusion strategy: method get invoked per each field, and must 
return true/false to skip/keep the field ie:
    private class MyExclusionStrategy implements ExclusionStrategy {

        public boolean shouldSkipClass(Class<?> clazz) {
            return false;
        }

        public boolean shouldSkipField(FieldAttributes f) {
            String cn = (f.getDeclaringClass().getCanonicalName() + '.' + f.getName());
            for (String s : skip)
                if (cn.contains(s)) return true;
            return false;
        }
    }
in this way, we can build a macro serializer object, that can be configured 
on-the-fly with unwanted fields.

3) probably the most important feature, be able to serializer 
private/protected/transient fields (and toggle between them). on GSON by 
default, you get the full load of all fields per each class, then you can
                .excludeFieldsWithModifiers(java.lang.reflect.Modifier.TRANSIENT)

to remove some modifiers from the serialization. This will add a great value 
imho, sometimes is useful to serialize private/package_protected fields 
(transient should be keep off, the meaning of transient is exactly 'don't 
serialize it please') but, if you think about keep the state of a bean, a 
private VAR must be serialized for sure

Original issue reported on code.google.com by [email protected] on 23 Nov 2012 at 2:57

OSGi-ify your jar so it can be loaded as a bundle

OSGi Bundles are jars with some extra meta-data in the manifest file.  This 
data is easily added with the apache felix bundle plugin.

To fix, make the following changes to your pom:

1. Change <packaging> to 'bundle' (it's now 'jar'). This will still generate a 
JAR file that works in other situations, but also includes metadata that OSGi 
needs.

2. Add this plugin to your build section:


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>


That's it!  Easy. And all of us who use OSGi for our deployment engine will 
love you unreservedly, buy you a beer when we see you and think warmly you on a 
regular basis.

Original issue reported on code.google.com by [email protected] on 29 Feb 2012 at 8:54

JSONParser of json-smart is not throwing exception for invalid json string

What steps will reproduce the problem?
1. Create JSONParser with mode as RFC4627
2. try to parse string "{ \"param1\'\': value1, \"param2\": \"value2\" }" which 
invalid format


What is the expected output? What do you see instead?
It should throw exception, instead it's getting parsed as valid

What version of the product are you using? On what operating system?
1.1.1

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 10 Jul 2014 at 10:51

Duplicate names for property should not be permitted as per RFC 4627

What steps will reproduce the problem?
JSONValue.parseStrict("{\"name\":123, \"name\":123}");

What is the expected output? What do you see instead?
As per RFC 4627, duplicate names are not allowed.  (2.2 ... The names within an 
object SHOULD be unique.).  An error should occur.

What version of the product are you using? On what operating system?
Java 1.6, Windows 7, Trunk as of June 13th 2011

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Jun 2011 at 12:32

escape4web minor change

can we please change a small line of code here?


JStylerObj.java

public void escape(String s, Appendable sb) {
      try {

                           for (int i = 0; i < s.length(); i++) {
}
     }
}


can we replace s.lenght() with int l = s.length() and use this var?
i think that there will be a little improve of performance, will avoid the 
continuous call to an external object method

Original issue reported on code.google.com by [email protected] on 28 Nov 2012 at 1:27

Issue with json validation/parse and quotes

What steps will reproduce the problem?
1. Execute this code

String test = 
"[{\"key\":\"value\",\"newKey\":[{\"\"tabKey\":[\"tab1\",\"tab2\"]}]}]";
System.out.println(JSONValue.isValidJson(test));
System.out.println(JSONValue.isValidJsonStrict(test));
JSONParser parser = new JSONParser(JSONParser.MODE_RFC4627);
System.out.println("MODE_RFC4627     : " + parser.parse(test));
parser = new JSONParser(JSONParser.MODE_STRICTEST);
System.out.println("MODE_STRICTEST   : " + parser.parse(test));
parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
System.out.println("MODE_JSON_SIMPLE : " + parser.parse(test));
parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
System.out.println("MODE_PERMISSIVE  : " + parser.parse(test));

What is the expected output? What do you see instead?

An exception should be thrown somewhere and I think both methods isValidJson() 
and isValidJsonStrict() should return false.

This is the output:

true
true
MODE_RFC4627     : [{"newKey":[{"":["tab1","tab2"]}],"key":"value"}]
MODE_STRICTEST   : [{"newKey":[{"":["tab1","tab2"]}],"key":"value"}]
MODE_JSON_SIMPLE : [{"newKey":[{"":["tab1","tab2"]}],"key":"value"}]
MODE_PERMISSIVE  : [{"newKey":[{"":["tab1","tab2"]}],"key":"value"}]

As you can see, tabKey does not appear, just nothing instead. 

When I put ""tabKey" in the string, nothing appear, if I put "tabKey"", it 
works normally (tabKey appears). But in both case, we should have false, false 
+ exception.


What version of the product are you using? On what operating system?

Version 1.1.1 / Win7

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 28 Jun 2013 at 8:58

ConcurrentModificationException when writing object to storage

When executing the following code 

out = new FileWriter(new File("/sdcard/foo"));
((JSONObject) value).writeJSONString(out, JSONStyle.MAX_COMPRESS);

I get this stacktrace:

Failed to write object to SD: Member
java.util.ConcurrentModificationException
java.util.HashMap$HashIterator.nextEntry(HashMap.java:792)
java.util.HashMap$EntryIterator.next(HashMap.java:829)
java.util.HashMap$EntryIterator.next(HashMap.java:827)
04-09 17:20:04.786: E/com.flud.util.JsonUtils(537):     at 
net.minidev.json.JSONObject.writeJSONString(JSONObject.java:191)

This seems to only happen for JSONObject but not for JSONArray. I'm using v. 
1.1.1 on Android

Original issue reported on code.google.com by [email protected] on 9 Apr 2012 at 5:28

Parser throws unexpected StringIndexOutOfBoundsException

Parsing the following incomplete JSON strings throws an unexpected 
StringIndexOutOfBoundsException instead of a regular ParseException.

{"key":{}

{"key":

{"key":123

java.lang.StringIndexOutOfBoundsException: String index out of range: 10
        at java.lang.String.substring(String.java:1946)
        at net.minidev.json.parser.JSONParser.readNQString(JSONParser.java:216)
        at net.minidev.json.parser.JSONParser.readObject(JSONParser.java:341)
        at net.minidev.json.parser.JSONParser.readMain(JSONParser.java:132)
        at net.minidev.json.parser.JSONParser.parse(JSONParser.java:54)
        at net.minidev.json.JSONValue.parseWithException(JSONValue.java:183)
        at TestParseError.main(TestParseError.java:12)


Observed in JSON Smart 1.0.9.

See Java attachment for test case.

Original issue reported on code.google.com by [email protected] on 14 Oct 2011 at 10:50

Attachments:

invalid json gets parsed successfully in JSONParser.MODE_RFC4627

version used: 1.0.9

new JSONParser(JSONParser.MODE_RFC4627).parse("{\"1\":\"one\"\"2\":\"two\"}")

the above line throws parse exception; where as following line doesn't:

new JSONParser(JSONParser.MODE_RFC4627).parse("{\"1\":\"one\"\n\"2\":\"two\"}")

note that inserting \n makes it parsed successfully

Original issue reported on code.google.com by [email protected] on 22 Oct 2011 at 7:30

Replace all usages of StringBuffer with StringBuilder

The thread-safe StringBuffer class is used throughout the project
but most references are for local variables,
hence it can be safely replaced by the StringBuilder,
as suggested by the JDK javadocs.

VERSION:
module(v1), svn(1459912)

Original issue reported on code.google.com by [email protected] on 12 Apr 2013 at 3:04

JSONValue.parse returns float instead of string with MAX_COMPRESSION

I am de-/serializing Java objects using JSON. The objects often contain a UUID 
identifier generated by a database or Java code. If using max compression if 
the UUID "looks" like a floating point number the parser generates wrong values.

Test code:
JSONArray array = (JSONArray) JSONValue.parse(json);
array.get(0).toString()

With MAX_COMPRESSION (uuid_child value is wrong)
Input JSON: 
[{uuid_child:58860611416142319131902418361e88,uuid_parent:563a5570932e409e9621e1
8e5a17d6a5}]
Parsed JSON: 
{"uuid_child":5.8860611416142319131902418361E+116,"uuid_parent":"563a5570932e409
e9621e18e5a17d6a5"}

With LT_COMPRESS works:
Input JSON: 
[{"uuid_child":"58860611416142319131902418361e88","uuid_parent":"563a5570932e409
e9621e18e5a17d6a5"}]
Parsed JSON: 
{"uuid_child":"58860611416142319131902418361e88","uuid_parent":"563a5570932e409e
9621e18e5a17d6a5"}902418361e88","uuid_parent":"563a5570932e409e9621e18e5a17d6a5"
}

This happens with the current stable release json-smart-1.2. Haven't tested 
other versions by now.

Original issue reported on code.google.com by [email protected] on 19 Feb 2014 at 11:37

Support for reading ASCII hexidecimal excape sequences

Some webservices provide JSON with ascii hex excape sequences in them. 
json-smart should support this...

What steps will reproduce the problem?
1. Attempt to parse some JSON which contains an ASCII hex excape sequence like 
\x27
2.
3.

What is the expected output? What do you see instead?
\x27 should be parsed as '

What version of the product are you using? On what operating system?
V1.1.1

Please provide any additional information below.

I made the following changes to support ascii hex excape sequences...
In JSONParserBase:
In readString2()

                case 'u':
                    sb.append(readUnicode());
                case 'x'://<--- Added line
                    sb.append(readAsciHexExcapeCode());//<--- Added line


    protected char readAsciHexExcapeCode() throws IOException, ParseException
    {
        return readUnicode(2);
    }

    protected char readUnicode() throws ParseException, IOException {
        return readUnicode(4);
    }

    protected char readUnicode(int totalChars) throws IOException, ParseException
    {
        int value = 0;
        for (int i = 0; i < totalChars; i++) {
            value = value * 16;
            read();
            if (c <= '9' && c >= '0')
                value += c - '0';
            else if (c <= 'F' && c >= 'A')
                value += (c - 'A') + 10;
            else if (c >= 'a' && c <= 'f')
                value += (c - 'a') + 10;
            else if (c == EOI)
                throw new ParseException(pos, ERROR_UNEXPECTED_EOF, "EOF");
            else
                throw new ParseException(pos, ERROR_UNEXPECTED_UNICODE, c);
        }
        return (char) value;
    }

Original issue reported on code.google.com by [email protected] on 8 May 2013 at 6:14

Empty array is invalid

What steps will reproduce the problem?
1. {"something":[]}

What is the expected output? What do you see instead?
The JSON string is deemed invalid in strict.  Shouldn't an empty array be valid?

What version of the product are you using? On what operating system?
1.0.8, Windows 7, JDK 1.6

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 1 Jul 2011 at 5:56

Strange problem - Inverting integer arrays numbers

Using this code:
JSONObject resultObject = new JSONObject();
resultObject.put("intArray", new int[]{1, 2, 50, 1234, 10000});
System.out.println("RESULT: " + resultObject.toJSONString());

The output is:
RESULT: {"intArray":[1,2,05,4321,00001]}

I'm using json-smart-1.1.jar

Original issue reported on code.google.com by [email protected] on 16 Mar 2012 at 5:27

Allow for strict JSON parsing?

Hi Uriel,

My name is Vladimir and I'm the maintainer of the JSON-RPC 2.0 Base library. It 
has traditionally used JSON simple for parsing. A user however suggested I look 
at your implementation. I must say the benchmarks look impressive, at least on 
paper. Good work!

What worries me is that your parser allows for a very wide set of input whereas 
I would prefer to receive a parse exception if the text doesn't comform to 
standard JSON as per RFC 4627. Would you consider adding a parse method with a 
"strict" option? For example:

JSONValue.parse(String s, boolean strict)

JSONParser.parse(String s, boolean strict)

etc...

Original issue reported on code.google.com by [email protected] on 16 May 2011 at 9:31

Patch for Jackson conformance test

There's a small bug in Jackson test in that it does not actually set 'obj' 
after parsing array value. Additionally while node.toString() should usually 
work, more correct method is to use mapper (there are some edge cases where two 
differ). This patch fixes these issues, so that 3 more tests pass for Jackson.

Original issue reported on code.google.com by [email protected] on 21 May 2011 at 10:37

Attachments:

Maven 1.0.9.1 should be 1.0.9-1

What steps will reproduce the problem?
1. Follow the instructions on http://code.google.com/p/json-smart/ for Maven

What is the expected output? What do you see instead?

The JAR cannot be found in the Maven repo.

Please provide any additional information below.

1.0.9.1 should be 1.0.9-1 ala

http://search.maven.org/remotecontent?filepath=net/minidev/json-smart/1.0.9-1/js
on-smart-1.0.9-1.pom

Original issue reported on code.google.com by [email protected] on 7 Dec 2011 at 4:07

Can add a method in JSONValue defined as follows:

Can add a method in JSONValue defined as follows:

public static Object parse(byte[] in, int beginIndex, int endIndex);


    beginIndex - the beginning index, inclusive.
    endIndex - the ending index, exclusive. 

It can brings great performance improvements for my program.

Original issue reported on code.google.com by [email protected] on 11 May 2012 at 2:13

anonation feature request

1. like @JsonIgnore of jackson, in case to ignore some feild.
2. set JSONStyle config to different class of so.
3. and so on.
json-smart will be more powerful.Thanks.





Original issue reported on code.google.com by [email protected] on 1 Oct 2011 at 5:58

parsing a single entity results in exception

parsing a string or stream with only "123":

java.lang.ArrayIndexOutOfBoundsException: -1
    at net.minidev.json.parser.JSONStreamParser.readNumber(JSONStreamParser.java:247)
    at net.minidev.json.parser.JSONStreamParser.readMain(JSONStreamParser.java:221)
    at net.minidev.json.parser.JSONStreamParser.parse(JSONStreamParser.java:75)
    at net.minidev.json.parser.JSONStreamParser.parse(JSONStreamParser.java:50)
    at net.minidev.json.parser.JSONParser.parse(JSONParser.java:147)

The error is different for a string than for a stream.

It should return an integer 123

json-smart 1.0.9 maven

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 23 Oct 2011 at 2:54

New compression type: write JSON strings with added line breaks for readability

This is a feature request.

Sometimes you want to use a json object as a configuration file, or you just 
want to write it to disk to examine it. It would be nice to have a new 
JSONStyle.VERBOSE for use in JSONObject.toJSONString() that would add full line 
breaks after each name/value pair, and before and after braces. The benefit is 
that the JSON strings would be easier for humans to read.

The style used in http://jsonlint.com/ is a good one.

Original issue reported on code.google.com by [email protected] on 10 Dec 2012 at 8:52

JSONValue.parse does not correctly decode UTF-8 bytes from an inputstream

What steps will reproduce the problem?
// Note that the testJsonString includes unicode characters and is UTF-8 endoded

String testJsonString = 
"{\"balance\":1000.21,\"num\":100,\"nickname\":null,\"is_vip\":true,\"Sinhalese\
":\"සිංහල ජාතිය\",\"name\":\"foo\"}";

ByteArrayInputStream bis = new 
ByteArrayInputStream(testJsonString.getBytes(StandardCharsets.UTF_8));

JSONObject obj = JSONValue.parse(bis, JSONObject.class);

obj.get("Sinhalese"); // result is incorrect


What is the expected output? What do you see instead?

I would expect obj.get("Sinhalese") to return the characters in the original 
UTF-8 String


What version of the product are you using? On what operating system?

Using json-smart 2.0, openjdk 7 on freebsd


Please provide any additional information below.

Note that:

JSONValue.parse(ByteStreams.toByteArray(bis), JSONObject.class);

works correctly. So the code works fine when decoding byte arrays

Original issue reported on code.google.com by [email protected] on 13 Sep 2014 at 6:42

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.