From 5c455732176f074d34ab082345d7346c903aec2c Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 30 Aug 2022 12:33:54 +0100 Subject: [PATCH] Add some documentation --- Sources/XXClient/Helpers/JSONHelpers.swift | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Sources/XXClient/Helpers/JSONHelpers.swift b/Sources/XXClient/Helpers/JSONHelpers.swift index eb719ec9..7527ac9a 100644 --- a/Sources/XXClient/Helpers/JSONHelpers.swift +++ b/Sources/XXClient/Helpers/JSONHelpers.swift @@ -1,5 +1,29 @@ 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( in input: Data, at key: String @@ -18,6 +42,30 @@ func convertJsonNumberToString( 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( in input: Data, at key: String -- GitLab