Browse Source

Merge pull request #13 from karldmoore/master

Preserve key ordering when serializing and parsing
pull/15/merge
kallestenflo 12 years ago
parent
commit
d0c6796413
  1. 7
      json-path/src/main/java/com/jayway/jsonpath/spi/impl/JsonSmartJsonProvider.java

7
json-path/src/main/java/com/jayway/jsonpath/spi/impl/JsonSmartJsonProvider.java

@ -18,6 +18,7 @@ import com.jayway.jsonpath.InvalidJsonException;
import com.jayway.jsonpath.spi.Mode;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import net.minidev.json.parser.ContainerFactory;
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
@ -55,7 +56,7 @@ public class JsonSmartJsonProvider extends AbstractJsonProvider {
public Object parse(String json) {
try {
return parser.parse(json);
return parser.parse(json, ContainerFactory.FACTORY_ORDERED);
} catch (ParseException e) {
throw new InvalidJsonException(e);
}
@ -64,7 +65,7 @@ public class JsonSmartJsonProvider extends AbstractJsonProvider {
@Override
public Object parse(Reader jsonReader) throws InvalidJsonException {
try {
return parser.parse(jsonReader);
return parser.parse(jsonReader, ContainerFactory.FACTORY_ORDERED);
} catch (ParseException e) {
throw new InvalidJsonException(e);
}
@ -73,7 +74,7 @@ public class JsonSmartJsonProvider extends AbstractJsonProvider {
@Override
public Object parse(InputStream jsonStream) throws InvalidJsonException {
try {
return parser.parse(new InputStreamReader(jsonStream));
return parser.parse(new InputStreamReader(jsonStream), ContainerFactory.FACTORY_ORDERED);
} catch (ParseException e) {
throw new InvalidJsonException(e);
}

Loading…
Cancel
Save