Skip to content

Commit

Permalink
Merge pull request #35 from noppoMan/static-serialize
Browse files Browse the repository at this point in the history
make JSONSerializer serialize statically
  • Loading branch information
noppoMan committed May 22, 2017
2 parents a9df27f + 19e0664 commit 3f90d3f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Core/JSON/JSONSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private func serialize(dictionary: [String: Any]) throws -> String {
return s
}

struct JSONSerializer {
public func serialize(_ dictionary: [String: Any]) throws -> Data {
public struct JSONSerializer {
public static func serialize(_ dictionary: [String: Any]) throws -> Data {
let jsonString = try "{" + Core.serialize(dictionary: dictionary) + "}"
return jsonString.data(using: .utf8) ?? Data()
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Message/Body.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extension Body {
if jsonDictionary.isEmpty {
return nil
} else {
return try JSONSerializer().serialize(jsonDictionary)
return try JSONSerializer.serialize(jsonDictionary)
}

case .xml(let node):
Expand Down
2 changes: 1 addition & 1 deletion Tests/AWSSDKSwiftTests/Core/SerializableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SerializableTests: XCTestCase {

func testSerializeToDictionaryAndJSON() {
let dict = try! A().serializeToDictionary()
let data = try! JSONSerializer().serialize(dict)
let data = try! JSONSerializer.serialize(dict)
let jsonObect = try! JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
XCTAssertEqual(dict.count, jsonObect.count)
}
Expand Down

0 comments on commit 3f90d3f

Please sign in to comment.