Browse Source

Merge 5d1f857ded into bdfdb5fe10

pull/805/merge
dbrouwer GitHub 2 years ago
parent
commit
392af17e78
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1171 additions and 8 deletions
  1. +61
    -7
      json_object.c
  2. +13
    -0
      json_object.h
  3. +1
    -0
      tests/parse_flags.c
  4. +51
    -0
      tests/test1.c
  5. +5
    -0
      tests/test1.expected
  6. +1
    -1
      tests/test1.test
  7. +222
    -0
      tests/test1Formatted_compact_array.expected
  8. +5
    -0
      tests/test1Formatted_plain.expected
  9. +269
    -0
      tests/test1Formatted_pretty.expected
  10. +5
    -0
      tests/test1Formatted_spaced.expected
  11. +269
    -0
      tests/test1Formatted_spaced_pretty.expected
  12. +269
    -0
      tests/test1Formatted_spaced_pretty_pretty_tab.expected

+ 61
- 7
json_object.c View File

@@ -438,7 +438,7 @@ const char *json_object_to_json_string(struct json_object *jso)

static void indent(struct printbuf *pb, int level, int flags)
{
if (flags & JSON_C_TO_STRING_PRETTY)
if (flags & (JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY))
{
if (flags & JSON_C_TO_STRING_PRETTY_TAB)
{
@@ -458,10 +458,17 @@ static int json_object_object_to_json_string(struct json_object *jso, struct pri
{
int had_children = 0;
struct json_object_iter iter;
int compact_array_reset_flag = 0;

printbuf_strappend(pb, "{" /*}*/);
json_object_object_foreachC(jso, iter)
{
/* For objects that are not arrays, these flags are equivalent. */
if (flags & JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY)
{
flags = JSON_C_TO_STRING_PRETTY;
compact_array_reset_flag = 1;
}
if (had_children)
{
printbuf_strappend(pb, ",");
@@ -480,10 +487,19 @@ static int json_object_object_to_json_string(struct json_object *jso, struct pri
printbuf_strappend(pb, "\":");
if (iter.val == NULL)
printbuf_strappend(pb, "null");
else if (iter.val->_to_json_string(iter.val, pb, level + 1, flags) < 0)
return -1;
else
{
if (compact_array_reset_flag)
{
flags = JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY;
compact_array_reset_flag = 0;
}
int ret = iter.val->_to_json_string(iter.val, pb, level + 1, flags);
if (ret < 0)
return -1;
}
}
if ((flags & JSON_C_TO_STRING_PRETTY) && had_children)
if ((flags & (JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY)) && had_children)
{
printbuf_strappend(pb, "\n");
indent(pb, level, flags);
@@ -1376,28 +1392,66 @@ static int json_object_array_to_json_string(struct json_object *jso, struct prin
{
int had_children = 0;
size_t ii;
int compact_array_reset_flag = 0;
int compact_array_elements_on_line = 0;
const int COMPACT_ARRAY_ELEMENTS_PER_LINE_MAX = 15;

printbuf_strappend(pb, "[");
for (ii = 0; ii < json_object_array_length(jso); ii++)
{
struct json_object *val;
val = json_object_array_get_idx(jso, ii);
json_type val_type = json_object_get_type(val);

if (had_children)
{
printbuf_strappend(pb, ",");
}

/* Do not compactly print arrays with elements that are arrays, strings or objects. */
if ((flags & JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY) || compact_array_reset_flag)
{
if (compact_array_reset_flag)
{
flags = JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY;
compact_array_reset_flag = 0;
}
if ((val_type == json_type_array) || (val_type == json_type_string) || (val_type == json_type_object))
{
flags = JSON_C_TO_STRING_PRETTY;
compact_array_reset_flag = 1;
}
}

if (flags & JSON_C_TO_STRING_PRETTY)
printbuf_strappend(pb, "\n");

if (flags & JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY)
{
if (ii == 0 || compact_array_elements_on_line >= COMPACT_ARRAY_ELEMENTS_PER_LINE_MAX)
{
printbuf_strappend(pb, "\n");
indent(pb, level + 1, flags);
compact_array_elements_on_line = 0;
}
else
{
printbuf_strappend(pb, " ");
compact_array_elements_on_line++;
}
}
had_children = 1;
if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
printbuf_strappend(pb, " ");
indent(pb, level + 1, flags);
val = json_object_array_get_idx(jso, ii);
if (!(flags & JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY))
indent(pb, level + 1, flags);
if (val == NULL)
printbuf_strappend(pb, "null");
else if (val->_to_json_string(val, pb, level + 1, flags) < 0)
return -1;

}
if ((flags & JSON_C_TO_STRING_PRETTY) && had_children)
if ((flags & (JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY)) && had_children)
{
printbuf_strappend(pb, "\n");
indent(pb, level, flags);


+ 13
- 0
json_object.h View File

@@ -74,6 +74,19 @@ extern "C" {
*/
#define JSON_C_TO_STRING_NOSLASHESCAPE (1 << 4)

/**
* A flag for the json_object_to_json_string_ext() and
* json_object_to_file_ext() functions which causes
* the output to be formatted.
* The format is the same as JSON_C_TO_STRING_PRETTY except
* that arrays with elements with the following types:
* json_type_null,
* json_type_boolean,
* json_type_double,
* json_type_int
* are formatted compactly with 16 elements (instead of 1) per line.
*/
#define JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY (1 << 5)
/**
* A flag for the json_object_object_add_ex function which
* causes the value to be added without a check if it already exists.


+ 1
- 0
tests/parse_flags.c View File

@@ -24,6 +24,7 @@ static struct
{"spaced", JSON_C_TO_STRING_SPACED},
{"pretty", JSON_C_TO_STRING_PRETTY},
{"pretty_tab", JSON_C_TO_STRING_PRETTY_TAB},
{"compact_array", JSON_C_TO_STRING_PRETTY_COMPACT_ARRAY},
};

#ifndef NELEM


+ 51
- 0
tests/test1.c View File

@@ -338,6 +338,57 @@ int main(int argc, char **argv)
my_array = NULL;
}
#endif
const int TEST_ARRAY_LENGTH = 50;

/* Arrays with string elements should not be printed compactly. */
json_object *my_long_array_of_strings = json_object_new_array();
char str[TEST_ARRAY_LENGTH];
for (int i = 0; i < TEST_ARRAY_LENGTH; i++) {
sprintf(&str[i], "%d", i);
json_object_array_add(my_long_array_of_strings, json_object_new_string(str));
}
printf("my_long_array_of_strings.to_string()=%s\n", json_object_to_json_string(my_long_array_of_strings));
json_object_put(my_long_array_of_strings);

/* Arrays with elements which are themselves arrays should not be printed compactly. */
json_object *my_long_array_of_arrays = json_object_new_array();
for (int i = 0; i < TEST_ARRAY_LENGTH; i++)
json_object_array_add(my_long_array_of_arrays, json_object_new_array());
printf("my_long_array_of_arrays.to_string()=%s\n", json_object_to_json_string(my_long_array_of_arrays));
json_object_put(my_long_array_of_arrays);

/* Arrays with int elements are printed compactly. */
json_object *my_long_array_of_int = json_object_new_array();
for (int i = 0; i < TEST_ARRAY_LENGTH; i++)
json_object_array_add(my_long_array_of_int, json_object_new_int(i * 100000000));
printf("my_long_array_of_int.to_string()=%s\n", json_object_to_json_string(my_long_array_of_int));
json_object_put(my_long_array_of_int);

/* Arrays with int elements that are null are printed compactly. */
json_object *my_long_array_of_null = json_object_new_array();
for (int i = 0; i < TEST_ARRAY_LENGTH; i++)
json_object_array_add(my_long_array_of_null, NULL);
printf("my_long_array_of_null.to_string()=%s\n", json_object_to_json_string(my_long_array_of_null));
json_object_put(my_long_array_of_null);

/* Arrays nested within objects should still be printed compactly. */
json_object *my_long_array_parent = json_object_new_object();
struct json_object *a_object = json_object_new_int(3);
json_object_object_add(my_long_array_parent, "a_object", a_object);
struct json_object *b_object = json_object_new_string("b_object");
json_object_object_add(my_long_array_parent, "b_object", b_object);
struct json_object *c_object = json_object_new_object();
struct json_object *d_object = json_object_new_object();
struct json_object *e_object = json_object_new_string("e_object");
json_object *my_long_array_of_ints = json_object_new_array();
for (int i = 0; i < TEST_ARRAY_LENGTH; i++)
json_object_array_add(my_long_array_of_ints, json_object_new_int(i));
json_object_object_add(d_object, "e_object", e_object);
json_object_object_add(d_object, "my_long_array_of_ints", my_long_array_of_ints);
json_object_object_add(c_object, "d_object", d_object);
json_object_object_add(my_long_array_parent, "c_object", c_object);
printf("my_long_array_parent.to_string()=%s\n", json_object_to_json_string(my_long_array_parent));
json_object_put(my_long_array_parent);

json_object_put(my_string);
json_object_put(my_int);


+ 5
- 0
tests/test1.expected View File

@@ -76,3 +76,8 @@ my_object=
bool0: false
bool1: true
my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
my_long_array_of_int.to_string()=[ 0, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000, 1500000000, 1600000000, 1700000000, 1800000000, 1900000000, 2000000000, 2100000000, -2094967296, -1994967296, -1894967296, -1794967296, -1694967296, -1594967296, -1494967296, -1394967296, -1294967296, -1194967296, -1094967296, -994967296, -894967296, -794967296, -694967296, -594967296, -494967296, -394967296, -294967296, -194967296, -94967296, 5032704, 105032704, 205032704, 305032704, 405032704, 505032704, 605032704 ]
my_long_array_of_null.to_string()=[ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ]
my_long_array_of_strings.to_string()=[ "0", "01", "012", "0123", "01234", "012345", "0123456", "01234567", "012345678", "0123456789", "012345678910", "0123456789111", "01234567891112", "012345678911113", "0123456789111114", "01234567891111115", "012345678911111116", "0123456789111111117", "01234567891111111118", "012345678911111111119", "0123456789111111111120", "01234567891111111111221", "012345678911111111112222", "0123456789111111111122223", "01234567891111111111222224", "012345678911111111112222225", "0123456789111111111122222226", "01234567891111111111222222227", "012345678911111111112222222228", "0123456789111111111122222222229", "01234567891111111111222222222230", "012345678911111111112222222222331", "0123456789111111111122222222223332", "01234567891111111111222222222233333", "012345678911111111112222222222333334", "0123456789111111111122222222223333335", "01234567891111111111222222222233333336", "012345678911111111112222222222333333337", "0123456789111111111122222222223333333338", "01234567891111111111222222222233333333339", "012345678911111111112222222222333333333340", "0123456789111111111122222222223333333333441", "01234567891111111111222222222233333333334442", "012345678911111111112222222222333333333344443", "0123456789111111111122222222223333333333444444", "01234567891111111111222222222233333333334444445", "012345678911111111112222222222333333333344444446", "0123456789111111111122222222223333333333444444447", "01234567891111111111222222222233333333334444444448", "012345678911111111112222222222333333333344444444449" ]
my_long_array_of_arrays.to_string()=[ [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ] ]
my_long_array_parent.to_string()={ "a_object": 3, "b_object": "b_object", "c_object": { "d_object": { "e_object": "e_object", "my_long_array_of_ints": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 ] } } }

+ 1
- 1
tests/test1.test View File

@@ -11,7 +11,7 @@ fi
run_output_test test1
_err=$?

for flag in plain spaced pretty ; do
for flag in plain spaced pretty compact_array ; do
run_output_test -o test1Formatted_${flag} test1Formatted ${flag}
_err2=$?
if [ $_err -eq 0 ] ; then


+ 222
- 0
tests/test1Formatted_compact_array.expected View File

@@ -0,0 +1,222 @@
my_string=
my_string.to_string()="\t"
my_string=\
my_string.to_string()="\\"
my_string=/
my_string.to_string()="\/"
my_string.to_string(NOSLASHESCAPE)="/"
my_string=/foo/bar/baz
my_string.to_string()="\/foo\/bar\/baz"
my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
my_string=foo
my_string.to_string()="foo"
my_int=9
my_int.to_string()=9
my_null.to_string()=null
my_array=
[0]=1
[1]=2
[2]=3
[3]=null
[4]=5
my_array.to_string()=[
1, 2, 3, null, 5
]
my_array=
[0]=1
[1]=2
[2]=3
[3]=4
[4]=5
[5]=null
[6]=7
my_array.to_string()=[1,2,3,4,5,null,7]
after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7]
after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7]
after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7]
after del_idx(0,1)=0, my_array.to_string()=[5,null,7]
after del_idx(0,1)=0, my_array.to_string()=[null,7]
after del_idx(0,1)=0, my_array.to_string()=[7]
after del_idx(0,1)=0, my_array.to_string()=[]
after del_idx(0,1)=-1, my_array.to_string()=[]
after del_idx(0,7)=0, my_array.to_string()=[]
after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7]
after del_idx(0,6)=0, my_array.to_string()=[7]
after adding more entries, my_array.to_string()=[7,"s1","s2","s3"]
my_array=
[0]=1
[1]=2
[2]=3
[3]=4
[4]=5
[5]=null
[6]=7
my_array.to_string()=[1,2,3,4,5,null,7]
put_idx(5,6)=0
put_idx(63,0)=0
put_idx(129,0)=0
put_idx(SIZE_T_MAX,0)=-1
my_array=
[0]=3
[1]=1
[2]=2
[3]=null
[4]=0
my_array.to_string()=[
3, 1, 2, null, 0
]
my_array=
[0]=null
[1]=0
[2]=1
[3]=2
[4]=3
my_array.to_string()=[
null, 0, 1, 2, 3
]
find json_object(1) in my_array successfully: 1
baz_obj.to_string()="fark"
my_object=
abc: 12
foo: "bar"
bool0: false
bool1: true
my_object.to_string()={
"abc":12,
"foo":"bar",
"bool0":false,
"bool1":true,
"empty_array":[],
"empty_obj":{}
}
my_long_array_of_int.to_string()=[
0, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000, 1500000000,
1600000000, 1700000000, 1800000000, 1900000000, 2000000000, 2100000000, -2094967296, -1994967296, -1894967296, -1794967296, -1694967296, -1594967296, -1494967296, -1394967296, -1294967296, -1194967296,
-1094967296, -994967296, -894967296, -794967296, -694967296, -594967296, -494967296, -394967296, -294967296, -194967296, -94967296, 5032704, 105032704, 205032704, 305032704, 405032704,
505032704, 605032704
]
my_long_array_of_null.to_string()=[
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null
]
my_long_array_of_strings.to_string()=[
"0",
"01",
"012",
"0123",
"01234",
"012345",
"0123456",
"01234567",
"012345678",
"0123456789",
"012345678910",
"0123456789111",
"01234567891112",
"012345678911113",
"0123456789111114",
"01234567891111115",
"012345678911111116",
"0123456789111111117",
"01234567891111111118",
"012345678911111111119",
"0123456789111111111120",
"01234567891111111111221",
"012345678911111111112222",
"0123456789111111111122223",
"01234567891111111111222224",
"012345678911111111112222225",
"0123456789111111111122222226",
"01234567891111111111222222227",
"012345678911111111112222222228",
"0123456789111111111122222222229",
"01234567891111111111222222222230",
"012345678911111111112222222222331",
"0123456789111111111122222222223332",
"01234567891111111111222222222233333",
"012345678911111111112222222222333334",
"0123456789111111111122222222223333335",
"01234567891111111111222222222233333336",
"012345678911111111112222222222333333337",
"0123456789111111111122222222223333333338",
"01234567891111111111222222222233333333339",
"012345678911111111112222222222333333333340",
"0123456789111111111122222222223333333333441",
"01234567891111111111222222222233333333334442",
"012345678911111111112222222222333333333344443",
"0123456789111111111122222222223333333333444444",
"01234567891111111111222222222233333333334444445",
"012345678911111111112222222222333333333344444446",
"0123456789111111111122222222223333333333444444447",
"01234567891111111111222222222233333333334444444448",
"012345678911111111112222222222333333333344444444449"
]
my_long_array_of_arrays.to_string()=[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
my_long_array_parent.to_string()={
"a_object":3,
"b_object":"b_object",
"c_object":{
"d_object":{
"e_object":"e_object",
"my_long_array_of_ints":[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49
]
}
}
}

+ 5
- 0
tests/test1Formatted_plain.expected View File

@@ -76,3 +76,8 @@ my_object=
bool0: false
bool1: true
my_object.to_string()={"abc":12,"foo":"bar","bool0":false,"bool1":true,"empty_array":[],"empty_obj":{}}
my_long_array_of_int.to_string()=[0,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,1100000000,1200000000,1300000000,1400000000,1500000000,1600000000,1700000000,1800000000,1900000000,2000000000,2100000000,-2094967296,-1994967296,-1894967296,-1794967296,-1694967296,-1594967296,-1494967296,-1394967296,-1294967296,-1194967296,-1094967296,-994967296,-894967296,-794967296,-694967296,-594967296,-494967296,-394967296,-294967296,-194967296,-94967296,5032704,105032704,205032704,305032704,405032704,505032704,605032704]
my_long_array_of_null.to_string()=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]
my_long_array_of_strings.to_string()=["0","01","012","0123","01234","012345","0123456","01234567","012345678","0123456789","012345678910","0123456789111","01234567891112","012345678911113","0123456789111114","01234567891111115","012345678911111116","0123456789111111117","01234567891111111118","012345678911111111119","0123456789111111111120","01234567891111111111221","012345678911111111112222","0123456789111111111122223","01234567891111111111222224","012345678911111111112222225","0123456789111111111122222226","01234567891111111111222222227","012345678911111111112222222228","0123456789111111111122222222229","01234567891111111111222222222230","012345678911111111112222222222331","0123456789111111111122222222223332","01234567891111111111222222222233333","012345678911111111112222222222333334","0123456789111111111122222222223333335","01234567891111111111222222222233333336","012345678911111111112222222222333333337","0123456789111111111122222222223333333338","01234567891111111111222222222233333333339","012345678911111111112222222222333333333340","0123456789111111111122222222223333333333441","01234567891111111111222222222233333333334442","012345678911111111112222222222333333333344443","0123456789111111111122222222223333333333444444","01234567891111111111222222222233333333334444445","012345678911111111112222222222333333333344444446","0123456789111111111122222222223333333333444444447","01234567891111111111222222222233333333334444444448","012345678911111111112222222222333333333344444444449"]
my_long_array_of_arrays.to_string()=[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
my_long_array_parent.to_string()={"a_object":3,"b_object":"b_object","c_object":{"d_object":{"e_object":"e_object","my_long_array_of_ints":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]}}}

+ 269
- 0
tests/test1Formatted_pretty.expected View File

@@ -101,3 +101,272 @@ my_object.to_string()={
"empty_array":[],
"empty_obj":{}
}
my_long_array_of_int.to_string()=[
0,
100000000,
200000000,
300000000,
400000000,
500000000,
600000000,
700000000,
800000000,
900000000,
1000000000,
1100000000,
1200000000,
1300000000,
1400000000,
1500000000,
1600000000,
1700000000,
1800000000,
1900000000,
2000000000,
2100000000,
-2094967296,
-1994967296,
-1894967296,
-1794967296,
-1694967296,
-1594967296,
-1494967296,
-1394967296,
-1294967296,
-1194967296,
-1094967296,
-994967296,
-894967296,
-794967296,
-694967296,
-594967296,
-494967296,
-394967296,
-294967296,
-194967296,
-94967296,
5032704,
105032704,
205032704,
305032704,
405032704,
505032704,
605032704
]
my_long_array_of_null.to_string()=[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
my_long_array_of_strings.to_string()=[
"0",
"01",
"012",
"0123",
"01234",
"012345",
"0123456",
"01234567",
"012345678",
"0123456789",
"012345678910",
"0123456789111",
"01234567891112",
"012345678911113",
"0123456789111114",
"01234567891111115",
"012345678911111116",
"0123456789111111117",
"01234567891111111118",
"012345678911111111119",
"0123456789111111111120",
"01234567891111111111221",
"012345678911111111112222",
"0123456789111111111122223",
"01234567891111111111222224",
"012345678911111111112222225",
"0123456789111111111122222226",
"01234567891111111111222222227",
"012345678911111111112222222228",
"0123456789111111111122222222229",
"01234567891111111111222222222230",
"012345678911111111112222222222331",
"0123456789111111111122222222223332",
"01234567891111111111222222222233333",
"012345678911111111112222222222333334",
"0123456789111111111122222222223333335",
"01234567891111111111222222222233333336",
"012345678911111111112222222222333333337",
"0123456789111111111122222222223333333338",
"01234567891111111111222222222233333333339",
"012345678911111111112222222222333333333340",
"0123456789111111111122222222223333333333441",
"01234567891111111111222222222233333333334442",
"012345678911111111112222222222333333333344443",
"0123456789111111111122222222223333333333444444",
"01234567891111111111222222222233333333334444445",
"012345678911111111112222222222333333333344444446",
"0123456789111111111122222222223333333333444444447",
"01234567891111111111222222222233333333334444444448",
"012345678911111111112222222222333333333344444444449"
]
my_long_array_of_arrays.to_string()=[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
my_long_array_parent.to_string()={
"a_object":3,
"b_object":"b_object",
"c_object":{
"d_object":{
"e_object":"e_object",
"my_long_array_of_ints":[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49
]
}
}
}

+ 5
- 0
tests/test1Formatted_spaced.expected View File

@@ -76,3 +76,8 @@ my_object=
bool0: false
bool1: true
my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
my_long_array_of_int.to_string()=[ 0, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 1100000000, 1200000000, 1300000000, 1400000000, 1500000000, 1600000000, 1700000000, 1800000000, 1900000000, 2000000000, 2100000000, -2094967296, -1994967296, -1894967296, -1794967296, -1694967296, -1594967296, -1494967296, -1394967296, -1294967296, -1194967296, -1094967296, -994967296, -894967296, -794967296, -694967296, -594967296, -494967296, -394967296, -294967296, -194967296, -94967296, 5032704, 105032704, 205032704, 305032704, 405032704, 505032704, 605032704 ]
my_long_array_of_null.to_string()=[ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ]
my_long_array_of_strings.to_string()=[ "0", "01", "012", "0123", "01234", "012345", "0123456", "01234567", "012345678", "0123456789", "012345678910", "0123456789111", "01234567891112", "012345678911113", "0123456789111114", "01234567891111115", "012345678911111116", "0123456789111111117", "01234567891111111118", "012345678911111111119", "0123456789111111111120", "01234567891111111111221", "012345678911111111112222", "0123456789111111111122223", "01234567891111111111222224", "012345678911111111112222225", "0123456789111111111122222226", "01234567891111111111222222227", "012345678911111111112222222228", "0123456789111111111122222222229", "01234567891111111111222222222230", "012345678911111111112222222222331", "0123456789111111111122222222223332", "01234567891111111111222222222233333", "012345678911111111112222222222333334", "0123456789111111111122222222223333335", "01234567891111111111222222222233333336", "012345678911111111112222222222333333337", "0123456789111111111122222222223333333338", "01234567891111111111222222222233333333339", "012345678911111111112222222222333333333340", "0123456789111111111122222222223333333333441", "01234567891111111111222222222233333333334442", "012345678911111111112222222222333333333344443", "0123456789111111111122222222223333333333444444", "01234567891111111111222222222233333333334444445", "012345678911111111112222222222333333333344444446", "0123456789111111111122222222223333333333444444447", "01234567891111111111222222222233333333334444444448", "012345678911111111112222222222333333333344444444449" ]
my_long_array_of_arrays.to_string()=[ [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ] ]
my_long_array_parent.to_string()={ "a_object": 3, "b_object": "b_object", "c_object": { "d_object": { "e_object": "e_object", "my_long_array_of_ints": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 ] } } }

+ 269
- 0
tests/test1Formatted_spaced_pretty.expected View File

@@ -101,3 +101,272 @@ my_object.to_string()={
"empty_array": [],
"empty_obj": {}
}
my_long_array_of_int.to_string()=[
0,
100000000,
200000000,
300000000,
400000000,
500000000,
600000000,
700000000,
800000000,
900000000,
1000000000,
1100000000,
1200000000,
1300000000,
1400000000,
1500000000,
1600000000,
1700000000,
1800000000,
1900000000,
2000000000,
2100000000,
-2094967296,
-1994967296,
-1894967296,
-1794967296,
-1694967296,
-1594967296,
-1494967296,
-1394967296,
-1294967296,
-1194967296,
-1094967296,
-994967296,
-894967296,
-794967296,
-694967296,
-594967296,
-494967296,
-394967296,
-294967296,
-194967296,
-94967296,
5032704,
105032704,
205032704,
305032704,
405032704,
505032704,
605032704
]
my_long_array_of_null.to_string()=[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
my_long_array_of_strings.to_string()=[
"0",
"01",
"012",
"0123",
"01234",
"012345",
"0123456",
"01234567",
"012345678",
"0123456789",
"012345678910",
"0123456789111",
"01234567891112",
"012345678911113",
"0123456789111114",
"01234567891111115",
"012345678911111116",
"0123456789111111117",
"01234567891111111118",
"012345678911111111119",
"0123456789111111111120",
"01234567891111111111221",
"012345678911111111112222",
"0123456789111111111122223",
"01234567891111111111222224",
"012345678911111111112222225",
"0123456789111111111122222226",
"01234567891111111111222222227",
"012345678911111111112222222228",
"0123456789111111111122222222229",
"01234567891111111111222222222230",
"012345678911111111112222222222331",
"0123456789111111111122222222223332",
"01234567891111111111222222222233333",
"012345678911111111112222222222333334",
"0123456789111111111122222222223333335",
"01234567891111111111222222222233333336",
"012345678911111111112222222222333333337",
"0123456789111111111122222222223333333338",
"01234567891111111111222222222233333333339",
"012345678911111111112222222222333333333340",
"0123456789111111111122222222223333333333441",
"01234567891111111111222222222233333333334442",
"012345678911111111112222222222333333333344443",
"0123456789111111111122222222223333333333444444",
"01234567891111111111222222222233333333334444445",
"012345678911111111112222222222333333333344444446",
"0123456789111111111122222222223333333333444444447",
"01234567891111111111222222222233333333334444444448",
"012345678911111111112222222222333333333344444444449"
]
my_long_array_of_arrays.to_string()=[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
my_long_array_parent.to_string()={
"a_object": 3,
"b_object": "b_object",
"c_object": {
"d_object": {
"e_object": "e_object",
"my_long_array_of_ints": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49
]
}
}
}

+ 269
- 0
tests/test1Formatted_spaced_pretty_pretty_tab.expected View File

@@ -101,3 +101,272 @@ my_object.to_string()={
"empty_array": [],
"empty_obj": {}
}
my_long_array_of_int.to_string()=[
0,
100000000,
200000000,
300000000,
400000000,
500000000,
600000000,
700000000,
800000000,
900000000,
1000000000,
1100000000,
1200000000,
1300000000,
1400000000,
1500000000,
1600000000,
1700000000,
1800000000,
1900000000,
2000000000,
2100000000,
-2094967296,
-1994967296,
-1894967296,
-1794967296,
-1694967296,
-1594967296,
-1494967296,
-1394967296,
-1294967296,
-1194967296,
-1094967296,
-994967296,
-894967296,
-794967296,
-694967296,
-594967296,
-494967296,
-394967296,
-294967296,
-194967296,
-94967296,
5032704,
105032704,
205032704,
305032704,
405032704,
505032704,
605032704
]
my_long_array_of_null.to_string()=[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
my_long_array_of_strings.to_string()=[
"0",
"01",
"012",
"0123",
"01234",
"012345",
"0123456",
"01234567",
"012345678",
"0123456789",
"012345678910",
"0123456789111",
"01234567891112",
"012345678911113",
"0123456789111114",
"01234567891111115",
"012345678911111116",
"0123456789111111117",
"01234567891111111118",
"012345678911111111119",
"0123456789111111111120",
"01234567891111111111221",
"012345678911111111112222",
"0123456789111111111122223",
"01234567891111111111222224",
"012345678911111111112222225",
"0123456789111111111122222226",
"01234567891111111111222222227",
"012345678911111111112222222228",
"0123456789111111111122222222229",
"01234567891111111111222222222230",
"012345678911111111112222222222331",
"0123456789111111111122222222223332",
"01234567891111111111222222222233333",
"012345678911111111112222222222333334",
"0123456789111111111122222222223333335",
"01234567891111111111222222222233333336",
"012345678911111111112222222222333333337",
"0123456789111111111122222222223333333338",
"01234567891111111111222222222233333333339",
"012345678911111111112222222222333333333340",
"0123456789111111111122222222223333333333441",
"01234567891111111111222222222233333333334442",
"012345678911111111112222222222333333333344443",
"0123456789111111111122222222223333333333444444",
"01234567891111111111222222222233333333334444445",
"012345678911111111112222222222333333333344444446",
"0123456789111111111122222222223333333333444444447",
"01234567891111111111222222222233333333334444444448",
"012345678911111111112222222222333333333344444444449"
]
my_long_array_of_arrays.to_string()=[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
my_long_array_parent.to_string()={
"a_object": 3,
"b_object": "b_object",
"c_object": {
"d_object": {
"e_object": "e_object",
"my_long_array_of_ints": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49
]
}
}
}

Loading…
Cancel
Save