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

Commit 48d31b7

Browse filesBrowse files
JSONzip value
1 parent b7a1aee commit 48d31b7
Copy full SHA for 48d31b7

File tree

Expand file treeCollapse file tree

3 files changed

+22
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-12
lines changed
Open diff view settings
Collapse file

‎zip/Compressor.java‎

Copy file name to clipboardExpand all lines: zip/Compressor.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ of this software and associated documentation files (the "Software"), to deal
3838
* JSONzip is a compression scheme for JSON text.
3939
*
4040
* @author JSON.org
41-
* @version 2014-04-21
41+
* @version 2014-04-28
4242
*/
4343

4444
/**
@@ -75,7 +75,7 @@ public Compressor(BitWriter bitwriter) {
7575
* 'e' is 13.
7676
*
7777
* @param digit
78-
* An ASCII character from a JSIN number.
78+
* An ASCII character from a JSON number.
7979
* @return
8080
*/
8181
private static int bcd(char digit) {
@@ -514,11 +514,11 @@ private void writeValue(Object value) throws JSONException {
514514
one();
515515
if (longer < int7) {
516516
zero();
517-
write((int) longer, 7);
517+
write((int)(longer - int4), 7);
518518
return;
519519
}
520520
one();
521-
write((int) longer, 14);
521+
write((int)(longer - int7), 14);
522522
return;
523523
}
524524
}
Collapse file

‎zip/Decompressor.java‎

Copy file name to clipboardExpand all lines: zip/Decompressor.java
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
3535
* JSONzip is a compression scheme for JSON text.
3636
*
3737
* @author JSON.org
38-
* @version 2014-04-21
38+
* @version 2014-04-28
3939
*/
4040

4141
public class Decompressor extends JSONzip {
@@ -288,7 +288,17 @@ private String readString() throws JSONException {
288288
private Object readValue() throws JSONException {
289289
switch (read(2)) {
290290
case 0:
291-
return new Integer(read(!bit() ? 4 : !bit() ? 7 : 14));
291+
int nr_bits = !bit() ? 4 : !bit() ? 7 : 14;
292+
int integer = read(nr_bits);
293+
switch (nr_bits) {
294+
case 7:
295+
integer += int4;
296+
break;
297+
case 14:
298+
integer += int7;
299+
break;
300+
}
301+
return new Integer(integer);
292302
case 1:
293303
byte[] bytes = new byte[256];
294304
int length = 0;
Collapse file

‎zip/JSONzip.java‎

Copy file name to clipboardExpand all lines: zip/JSONzip.java
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ of this software and associated documentation files (the "Software"), to deal
4444
* ADEQUATELY FOR PRODUCTION USE.
4545
*
4646
* @author JSON.org
47-
* @version 2014-04-21
47+
* @version 2014-04-28
4848
*/
4949
public abstract class JSONzip implements None, PostMortem {
5050
/**
@@ -63,19 +63,19 @@ public abstract class JSONzip implements None, PostMortem {
6363
};
6464

6565
/**
66-
* The number of integers that can be encoded in 4 bits.
66+
* The first positive integer than cannot be encoded in 4 bits.
6767
*/
6868
public static final long int4 = 16;
6969

7070
/**
71-
* The number of integers that can be encoded in 7 bits.
71+
* The first positive integer than cannot be encoded in 7 bits.
7272
*/
73-
public static final long int7 = 128;
73+
public static final long int7 = 144;
7474

7575
/**
76-
* The number of integers that can be encoded in 14 bits.
76+
* The first positive integer than cannot be encoded in 14 bits.
7777
*/
78-
public static final long int14 = 16384;
78+
public static final long int14 = 16528;
7979

8080
/**
8181
* The end of string code.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.