Skip to content
Snippets Groups Projects

Workaround for big numbers in JSONs

Merged Dariusz Rybicki requested to merge feature/json-bigint-coding into development
1 file
+ 48
0
Compare changes
  • Side-by-side
  • Inline
import Foundation
import Foundation
 
/// Replaces all numbers at provided key with string equivalents
 
///
 
/// Example input:
 
/// {
 
/// "key": 123,
 
/// "object": {
 
/// "hello": "world",
 
/// "key": 321
 
/// }
 
/// }
 
///
 
/// Example output:
 
/// {
 
/// "key": "123",
 
/// "object": {
 
/// "hello": "world",
 
/// "key": "321"
 
/// }
 
/// }
 
///
 
/// - Parameters:
 
/// - input: JSON data
 
/// - key: the key which values should be converted
 
/// - Returns: JSON data
func convertJsonNumberToString(
func convertJsonNumberToString(
in input: Data,
in input: Data,
at key: String
at key: String
@@ -18,6 +42,30 @@ func convertJsonNumberToString(
@@ -18,6 +42,30 @@ func convertJsonNumberToString(
return output
return output
}
}
 
/// Replaces all strings at provided key with number equivalents
 
///
 
/// Example input:
 
/// {
 
/// "key": "123",
 
/// "object": {
 
/// "hello": "world",
 
/// "key": "321"
 
/// }
 
/// }
 
///
 
/// Example output:
 
/// {
 
/// "key": 123,
 
/// "object": {
 
/// "hello": "world",
 
/// "key": 321
 
/// }
 
/// }
 
///
 
/// - Parameters:
 
/// - input: JSON data
 
/// - key: the key which values should be converted
 
/// - Returns: JSON data
func convertJsonStringToNumber(
func convertJsonStringToNumber(
in input: Data,
in input: Data,
at key: String
at key: String
Loading