Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions 13 src/main/java/com/jsoniter/IterImpl.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.jsoniter;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

import com.jsoniter.any.Any;
import com.jsoniter.spi.JsonException;
import com.jsoniter.spi.Slice;

import java.io.IOException;
import java.math.BigInteger;

class IterImpl {

private static BigInteger maxLong = BigInteger.valueOf(Long.MAX_VALUE);
Expand Down Expand Up @@ -469,7 +470,11 @@ static final double readDouble(final JsonIterator iter) throws IOException {
decimalPart = -decimalPart;
int decimalPlaces = iter.head - start;
if (decimalPlaces > 0 && decimalPlaces < IterImplNumber.POW10.length && (iter.head - oldHead) < 10) {
return value + (decimalPart / (double) IterImplNumber.POW10[decimalPlaces]);
BigDecimal integerPart = new BigDecimal(value);
BigDecimal fractionalPart = new BigDecimal((decimalPart / (double) IterImplNumber.POW10[decimalPlaces]));
BigDecimal result = integerPart.add(fractionalPart).setScale(decimalPlaces,BigDecimal.ROUND_HALF_UP);
double dvalue = result.doubleValue();
return dvalue;
} else {
iter.head = oldHead;
return IterImplForStreaming.readDoubleSlowPath(iter);
Expand Down
7 changes: 4 additions & 3 deletions 7 src/main/java/com/jsoniter/output/StreamImplString.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ private static void writeStringSlowPathWithoutEscapeUnicode(JsonStream stream, S
int firstPart = _surrogate;
_surrogate = 0;
// Ok, then, is the second part valid?
if (c < SURR2_FIRST || c > SURR2_LAST) {
throw new JsonException("Broken surrogate pair: first char 0x" + Integer.toHexString(firstPart) + ", second 0x" + Integer.toHexString(c) + "; illegal combination");
int secondPart = val.charAt(++i);
if (secondPart < SURR2_FIRST || secondPart > SURR2_LAST) {
throw new JsonException("Broken surrogate pair: first char 0x" + Integer.toHexString(firstPart) + ", second 0x" + Integer.toHexString(secondPart) + "; illegal combination");
}
c = 0x10000 + ((firstPart - SURR1_FIRST) << 10) + (c - SURR2_FIRST);
c = 0x10000 + ((firstPart - SURR1_FIRST) << 10) + (secondPart - SURR2_FIRST);
if (c > 0x10FFFF) { // illegal in JSON as well as in XML
throw new JsonException("illegalSurrogate");
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.