A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/apple/swift-corelibs-foundation/commit/b914527d4d560602afc90da29254e1f1571672dd below:

Drop NS from JSONSerialization · swiftlang/swift-corelibs-foundation@b914527 · GitHub

@@ -47,7 +47,7 @@ extension TestNSJSONSerialization {

47 47

func test_JSONObjectWithData_emptyObject() {

48 48

let subject = NSData(bytes: UnsafePointer<Void>([UInt8]([0x7B, 0x7D])), length: 2)

49 49 50 -

let object = try! NSJSONSerialization.jsonObject(with: subject, options: []) as? [String:Any]

50 +

let object = try! JSONSerialization.jsonObject(with: subject, options: []) as? [String:Any]

51 51

XCTAssertEqual(object?.count, 0)

52 52

}

53 53

@@ -75,7 +75,7 @@ extension TestNSJSONSerialization {

75 75

]

76 76 77 77

for (description, encoded) in subjects {

78 -

let result = try? NSJSONSerialization.jsonObject(with: NSData(bytes:UnsafePointer<Void>(encoded), length: encoded.count), options: [])

78 +

let result = try? JSONSerialization.jsonObject(with: NSData(bytes:UnsafePointer<Void>(encoded), length: encoded.count), options: [])

79 79

XCTAssertNotNil(result, description)

80 80

}

81 81

}

@@ -125,7 +125,7 @@ extension TestNSJSONSerialization {

125 125

XCTFail("Unable to convert string to data")

126 126

return

127 127

}

128 -

let t = try NSJSONSerialization.jsonObject(with: data, options: [])

128 +

let t = try JSONSerialization.jsonObject(with: data, options: [])

129 129

let result = t as? [String: Any]

130 130

XCTAssertEqual(result?.count, 0)

131 131

} catch {

@@ -141,7 +141,7 @@ extension TestNSJSONSerialization {

141 141

XCTFail("Unable to convert string to data")

142 142

return

143 143

}

144 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String: Any]

144 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]

145 145

XCTAssertEqual(result?["hello"] as? String, "world")

146 146

XCTAssertEqual(result?["swift"] as? String, "rocks")

147 147

}

@@ -158,7 +158,7 @@ extension TestNSJSONSerialization {

158 158

XCTFail("Unable to convert string to data")

159 159

return

160 160

}

161 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String : Any]

161 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any]

162 162

XCTAssertEqual(result?["title"] as? String, " hello world!!")

163 163

} catch{

164 164

XCTFail("Error thrown: \(error)")

@@ -176,7 +176,7 @@ extension TestNSJSONSerialization {

176 176

XCTFail("Unable to convert string to data")

177 177

return

178 178

}

179 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

179 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

180 180

XCTAssertEqual(result?.count, 0)

181 181

} catch {

182 182

XCTFail("Unexpected error: \(error)")

@@ -192,7 +192,7 @@ extension TestNSJSONSerialization {

192 192

XCTFail("Unable to convert string to data")

193 193

return

194 194

}

195 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

195 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

196 196

XCTAssertEqual(result?[0] as? String, "hello")

197 197

XCTAssertEqual(result?[1] as? String, "swift⚡️")

198 198

}

@@ -211,7 +211,7 @@ extension TestNSJSONSerialization {

211 211

XCTFail("Unable to convert string to data")

212 212

return

213 213

}

214 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

214 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

215 215

XCTAssertEqual(result?[0] as? String, "unicode")

216 216

XCTAssertEqual(result?[1] as? String, "Ģ")

217 217

XCTAssertEqual(result?[2] as? String, "😢")

@@ -231,7 +231,7 @@ extension TestNSJSONSerialization {

231 231

XCTFail("Unable to convert string to data")

232 232

return

233 233

}

234 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

234 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

235 235

XCTAssertEqual(result?[0] as? Bool, true)

236 236

XCTAssertEqual(result?[1] as? Bool, false)

237 237

XCTAssertEqual(result?[2] as? String, "hello")

@@ -254,7 +254,7 @@ extension TestNSJSONSerialization {

254 254

XCTFail("Unable to convert string to data")

255 255

return

256 256

}

257 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

257 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

258 258

XCTAssertEqual(result?[0] as? Int, 1)

259 259

XCTAssertEqual(result?[1] as? Int, -1)

260 260

XCTAssertEqual(result?[2] as? Double, 1.3)

@@ -275,7 +275,7 @@ extension TestNSJSONSerialization {

275 275

XCTFail("Unable to convert string to data")

276 276

return

277 277

}

278 -

let res = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

278 +

let res = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

279 279

let result = res?.flatMap { $0 as? String }

280 280

XCTAssertEqual(result?[0], "\"")

281 281

XCTAssertEqual(result?[1], "\\")

@@ -297,7 +297,7 @@ extension TestNSJSONSerialization {

297 297

XCTFail("Unable to convert string to data")

298 298

return

299 299

}

300 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

300 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

301 301

XCTAssertEqual(result?[0] as? String, "")

302 302

} catch {

303 303

XCTFail("Unexpected error: \(error)")

@@ -311,7 +311,7 @@ extension TestNSJSONSerialization {

311 311

XCTFail("Unable to convert string to data")

312 312

return

313 313

}

314 -

let result = try NSJSONSerialization.jsonObject(with: data, options: []) as? [Any]

314 +

let result = try JSONSerialization.jsonObject(with: data, options: []) as? [Any]

315 315

XCTAssertEqual(result?[0] as? String, "\u{1D11E}")

316 316

} catch {

317 317

XCTFail("Unexpected error: \(error)")

@@ -327,7 +327,7 @@ extension TestNSJSONSerialization {

327 327

XCTFail("Unable to convert string to data")

328 328

return

329 329

}

330 -

let result = try NSJSONSerialization.jsonObject(with: data, options: .allowFragments) as? Int

330 +

let result = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? Int

331 331

XCTAssertEqual(result, 3)

332 332

}

333 333

} catch {

@@ -344,7 +344,7 @@ extension TestNSJSONSerialization {

344 344

XCTFail("Unable to convert string to data")

345 345

return

346 346

}

347 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

347 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

348 348

XCTFail("Expected error: UnterminatedString")

349 349

} catch {

350 350

// Passing case; the object as unterminated

@@ -359,7 +359,7 @@ extension TestNSJSONSerialization {

359 359

XCTFail("Unable to convert string to data")

360 360

return

361 361

}

362 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

362 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

363 363

XCTFail("Expected error: Missing key for value")

364 364

} catch {

365 365

// Passing case; the key was missing for a value

@@ -374,7 +374,7 @@ extension TestNSJSONSerialization {

374 374

XCTFail("Unable to convert string to data")

375 375

return

376 376

}

377 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

377 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

378 378

XCTFail("Expected error: Unexpected end of file")

379 379

} catch {

380 380

// Success

@@ -389,7 +389,7 @@ extension TestNSJSONSerialization {

389 389

XCTFail("Unable to convert string to data")

390 390

return

391 391

}

392 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

392 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

393 393

XCTFail("Expected error: Invalid value")

394 394

} catch {

395 395

// Passing case; the value is invalid

@@ -404,7 +404,7 @@ extension TestNSJSONSerialization {

404 404

XCTFail("Unable to convert string to data")

405 405

return

406 406

}

407 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

407 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

408 408

XCTFail("Expected error: Invalid value")

409 409

} catch {

410 410

// passing case the value is invalid

@@ -419,7 +419,7 @@ extension TestNSJSONSerialization {

419 419

XCTFail("Unable to convert string to data")

420 420

return

421 421

}

422 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

422 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

423 423

XCTFail("Expected error: Invalid value")

424 424

} catch {

425 425

// Passing case; the element in the array is missing

@@ -434,7 +434,7 @@ extension TestNSJSONSerialization {

434 434

XCTFail("Unable to convert string to data")

435 435

return

436 436

}

437 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

437 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

438 438

XCTFail("Expected error: Badly formed array")

439 439

} catch {

440 440

// Passing case; the array is malformed

@@ -449,7 +449,7 @@ extension TestNSJSONSerialization {

449 449

XCTFail("Unable to convert string to data")

450 450

return

451 451

}

452 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: [])

452 +

let _ = try JSONSerialization.jsonObject(with: data, options: [])

453 453

XCTFail("Expected error: Invalid escape sequence")

454 454

} catch {

455 455

// Passing case; the escape sequence is invalid

@@ -463,7 +463,7 @@ extension TestNSJSONSerialization {

463 463

XCTFail("Unable to convert string to data")

464 464

return

465 465

}

466 -

let _ = try NSJSONSerialization.jsonObject(with: data, options: []) as? [String]

466 +

let _ = try JSONSerialization.jsonObject(with: data, options: []) as? [String]

467 467

XCTFail("Expected error: Missing Trailing Surrogate")

468 468

} catch {

469 469

// Passing case; the unicode character is malformed

@@ -525,7 +525,7 @@ extension TestNSJSONSerialization {

525 525

)

526 526

]

527 527

for testCase in trueJSON {

528 -

XCTAssertTrue(NSJSONSerialization.isValidJSONObject(testCase))

528 +

XCTAssertTrue(JSONSerialization.isValidJSONObject(testCase))

529 529

}

530 530

}

531 531

@@ -574,7 +574,7 @@ extension TestNSJSONSerialization {

574 574

)

575 575

]

576 576

for testCase in falseJSON {

577 -

XCTAssertFalse(NSJSONSerialization.isValidJSONObject(testCase))

577 +

XCTAssertFalse(JSONSerialization.isValidJSONObject(testCase))

578 578

}

579 579

}

580 580

@@ -597,7 +597,7 @@ extension TestNSJSONSerialization {

597 597

}

598 598 599 599

func trySerialize(_ obj: AnyObject) throws -> String {

600 -

let data = try NSJSONSerialization.data(withJSONObject: obj, options: [])

600 +

let data = try JSONSerialization.data(withJSONObject: obj, options: [])

601 601

guard let string = NSString(data: data, encoding: NSUTF8StringEncoding) else {

602 602

XCTFail("Unable to create string")

603 603

return ""


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4