Skip to content

Commit faa3a34

Browse files
authored
Merge pull request #256 from ferdnyc/deprecate-jsonreader
Remove Json:Reader
2 parents 9c76de6 + 744a4f3 commit faa3a34

34 files changed

+233
-81
lines changed

src/CacheDisk.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,12 @@ Json::Value CacheDisk::JsonValue() {
486486

487487
// Parse and append range data (if any)
488488
Json::Value ranges;
489-
Json::Reader reader;
490-
bool success = reader.parse( json_ranges, ranges );
489+
Json::CharReaderBuilder rbuilder;
490+
Json::CharReader* reader(rbuilder.newCharReader());
491+
492+
string errors;
493+
bool success = reader->parse( json_ranges.c_str(),
494+
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
491495
if (success)
492496
root["ranges"] = ranges;
493497

@@ -500,8 +504,12 @@ void CacheDisk::SetJson(string value) {
500504

501505
// Parse JSON string into JSON objects
502506
Json::Value root;
503-
Json::Reader reader;
504-
bool success = reader.parse( value, root );
507+
Json::CharReaderBuilder rbuilder;
508+
Json::CharReader* reader(rbuilder.newCharReader());
509+
510+
string errors;
511+
bool success = reader->parse( value.c_str(),
512+
value.c_str() + value.size(), &root, &errors );
505513
if (!success)
506514
// Raise exception
507515
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/CacheMemory.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,13 @@ Json::Value CacheMemory::JsonValue() {
340340

341341
// Parse and append range data (if any)
342342
Json::Value ranges;
343-
Json::Reader reader;
344-
bool success = reader.parse( json_ranges, ranges );
343+
Json::CharReaderBuilder rbuilder;
344+
Json::CharReader* reader(rbuilder.newCharReader());
345+
346+
string errors;
347+
bool success = reader->parse( json_ranges.c_str(),
348+
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
349+
345350
if (success)
346351
root["ranges"] = ranges;
347352

@@ -354,8 +359,12 @@ void CacheMemory::SetJson(string value) {
354359

355360
// Parse JSON string into JSON objects
356361
Json::Value root;
357-
Json::Reader reader;
358-
bool success = reader.parse( value, root );
362+
Json::CharReaderBuilder rbuilder;
363+
Json::CharReader* reader(rbuilder.newCharReader());
364+
365+
string errors;
366+
bool success = reader->parse( value.c_str(),
367+
value.c_str() + value.size(), &root, &errors );
359368
if (!success)
360369
// Raise exception
361370
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/ChunkReader.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ void ChunkReader::load_json()
7676

7777
// Parse JSON string into JSON objects
7878
Json::Value root;
79-
Json::Reader reader;
80-
bool success = reader.parse( json_string.str(), root );
79+
Json::CharReaderBuilder rbuilder;
80+
81+
string errors;
82+
bool success = Json::parseFromStream(rbuilder, json_string, &root, &errors);
8183
if (!success)
8284
// Raise exception
8385
throw InvalidJSON("Chunk folder could not be opened.", path);
@@ -278,8 +280,12 @@ void ChunkReader::SetJson(string value) {
278280

279281
// Parse JSON string into JSON objects
280282
Json::Value root;
281-
Json::Reader reader;
282-
bool success = reader.parse( value, root );
283+
Json::CharReaderBuilder rbuilder;
284+
Json::CharReader* reader(rbuilder.newCharReader());
285+
286+
string errors;
287+
bool success = reader->parse( value.c_str(),
288+
value.c_str() + value.size(), &root, &errors );
283289
if (!success)
284290
// Raise exception
285291
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Clip.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,12 @@ void Clip::SetJson(string value) {
786786

787787
// Parse JSON string into JSON objects
788788
Json::Value root;
789-
Json::Reader reader;
790-
bool success = reader.parse( value, root );
789+
Json::CharReaderBuilder rbuilder;
790+
Json::CharReader* reader(rbuilder.newCharReader());
791+
792+
string errors;
793+
bool success = reader->parse( value.c_str(),
794+
value.c_str() + value.size(), &root, &errors );
791795
if (!success)
792796
// Raise exception
793797
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Color.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ void Color::SetJson(string value) {
107107

108108
// Parse JSON string into JSON objects
109109
Json::Value root;
110-
Json::Reader reader;
111-
bool success = reader.parse( value, root );
110+
Json::CharReaderBuilder rbuilder;
111+
Json::CharReader* reader(rbuilder.newCharReader());
112+
113+
string errors;
114+
bool success = reader->parse( value.c_str(),
115+
value.c_str() + value.size(), &root, &errors );
112116
if (!success)
113117
// Raise exception
114118
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Coordinate.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ void Coordinate::SetJson(string value) {
7070

7171
// Parse JSON string into JSON objects
7272
Json::Value root;
73-
Json::Reader reader;
74-
bool success = reader.parse( value, root );
73+
Json::CharReaderBuilder rbuilder;
74+
Json::CharReader* reader(rbuilder.newCharReader());
75+
76+
string errors;
77+
bool success = reader->parse( value.c_str(),
78+
value.c_str() + value.size(), &root, &errors );
7579
if (!success)
7680
// Raise exception
7781
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/DecklinkReader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,12 @@ void DecklinkReader::SetJson(string value) {
265265

266266
// Parse JSON string into JSON objects
267267
Json::Value root;
268-
Json::Reader reader;
269-
bool success = reader.parse( value, root );
268+
Json::CharReaderBuilder rbuilder;
269+
Json::CharReader* reader(rbuilder.newCharReader());
270+
271+
string errors;
272+
bool success = reader->parse( value.c_str(),
273+
value.c_str() + value.size(), &root, &errors );
270274
if (!success)
271275
// Raise exception
272276
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/DummyReader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ void DummyReader::SetJson(string value) {
143143

144144
// Parse JSON string into JSON objects
145145
Json::Value root;
146-
Json::Reader reader;
147-
bool success = reader.parse( value, root );
146+
Json::CharReaderBuilder rbuilder;
147+
Json::CharReader* reader(rbuilder.newCharReader());
148+
149+
string errors;
150+
bool success = reader->parse( value.c_str(),
151+
value.c_str() + value.size(), &root, &errors );
148152
if (!success)
149153
// Raise exception
150154
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/EffectBase.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ void EffectBase::SetJson(string value) {
9999

100100
// Parse JSON string into JSON objects
101101
Json::Value root;
102-
Json::Reader reader;
103-
bool success = reader.parse( value, root );
102+
Json::CharReaderBuilder rbuilder;
103+
Json::CharReader* reader(rbuilder.newCharReader());
104+
105+
string errors;
106+
bool success = reader->parse( value.c_str(),
107+
value.c_str() + value.size(), &root, &errors );
104108
if (!success)
105109
// Raise exception
106110
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/FFmpegReader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,8 +2422,12 @@ void FFmpegReader::SetJson(string value) {
24222422

24232423
// Parse JSON string into JSON objects
24242424
Json::Value root;
2425-
Json::Reader reader;
2426-
bool success = reader.parse(value, root);
2425+
Json::CharReaderBuilder rbuilder;
2426+
Json::CharReader* reader(rbuilder.newCharReader());
2427+
2428+
string errors;
2429+
bool success = reader->parse(value.c_str(), value.c_str() + value.size(),
2430+
&root, &errors);
24272431
if (!success)
24282432
// Raise exception
24292433
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

0 commit comments

Comments
 (0)