mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
JSONzip value
This commit is contained in:
parent
b7a1aee4e1
commit
48d31b7f5c
3 changed files with 22 additions and 12 deletions
|
@ -38,7 +38,7 @@ import org.json.Kim;
|
||||||
* JSONzip is a compression scheme for JSON text.
|
* JSONzip is a compression scheme for JSON text.
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2014-04-21
|
* @version 2014-04-28
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,7 @@ public class Compressor extends JSONzip {
|
||||||
* 'e' is 13.
|
* 'e' is 13.
|
||||||
*
|
*
|
||||||
* @param digit
|
* @param digit
|
||||||
* An ASCII character from a JSIN number.
|
* An ASCII character from a JSON number.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static int bcd(char digit) {
|
private static int bcd(char digit) {
|
||||||
|
@ -514,11 +514,11 @@ public class Compressor extends JSONzip {
|
||||||
one();
|
one();
|
||||||
if (longer < int7) {
|
if (longer < int7) {
|
||||||
zero();
|
zero();
|
||||||
write((int) longer, 7);
|
write((int)(longer - int4), 7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
one();
|
one();
|
||||||
write((int) longer, 14);
|
write((int)(longer - int7), 14);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.json.Kim;
|
||||||
* JSONzip is a compression scheme for JSON text.
|
* JSONzip is a compression scheme for JSON text.
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2014-04-21
|
* @version 2014-04-28
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Decompressor extends JSONzip {
|
public class Decompressor extends JSONzip {
|
||||||
|
@ -288,7 +288,17 @@ public class Decompressor extends JSONzip {
|
||||||
private Object readValue() throws JSONException {
|
private Object readValue() throws JSONException {
|
||||||
switch (read(2)) {
|
switch (read(2)) {
|
||||||
case 0:
|
case 0:
|
||||||
return new Integer(read(!bit() ? 4 : !bit() ? 7 : 14));
|
int nr_bits = !bit() ? 4 : !bit() ? 7 : 14;
|
||||||
|
int integer = read(nr_bits);
|
||||||
|
switch (nr_bits) {
|
||||||
|
case 7:
|
||||||
|
integer += int4;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
integer += int7;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return new Integer(integer);
|
||||||
case 1:
|
case 1:
|
||||||
byte[] bytes = new byte[256];
|
byte[] bytes = new byte[256];
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
|
@ -44,7 +44,7 @@ package org.json.zip;
|
||||||
* ADEQUATELY FOR PRODUCTION USE.
|
* ADEQUATELY FOR PRODUCTION USE.
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2014-04-21
|
* @version 2014-04-28
|
||||||
*/
|
*/
|
||||||
public abstract class JSONzip implements None, PostMortem {
|
public abstract class JSONzip implements None, PostMortem {
|
||||||
/**
|
/**
|
||||||
|
@ -63,19 +63,19 @@ public abstract class JSONzip implements None, PostMortem {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of integers that can be encoded in 4 bits.
|
* The first positive integer than cannot be encoded in 4 bits.
|
||||||
*/
|
*/
|
||||||
public static final long int4 = 16;
|
public static final long int4 = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of integers that can be encoded in 7 bits.
|
* The first positive integer than cannot be encoded in 7 bits.
|
||||||
*/
|
*/
|
||||||
public static final long int7 = 128;
|
public static final long int7 = 144;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of integers that can be encoded in 14 bits.
|
* The first positive integer than cannot be encoded in 14 bits.
|
||||||
*/
|
*/
|
||||||
public static final long int14 = 16384;
|
public static final long int14 = 16528;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The end of string code.
|
* The end of string code.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue