To run the example project, clone the repo, and run pod install
from the Example directory first.
swift version 5.0 , iOS 12
JSONContentManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'JSONContentManager'
let's assume we have a json file like this :
{
"Employees": [
{
"name": "Joe",
"role": "developer"
},
{
"name": "wu jan",
"role": "product owner"
},
{
"name": "nicky",
"role": "sales manager"
}],
"Product": {
"name": "coffee machine",
"specs": {
"height": 40,
"weight": "12kg"
},
"bill": "you paid {0} of {1}."
}
}
First import JSONContentManager in your code
import JSONContentManager
Then create instance of JSONContentManager and pass json file name as a parameter
let contentManager = JSONContentManager.init(JSONFile: "ExampleJSONFile")
After that you can get value by passing its keys path like that :
let value = contentManager.value(from: "Product.specs.height") // value = 40
Also you can add external values to the value by passing it as placeHolders as follows:
let value = contentManager.stringValue(from: "Product.bill",
placeholders: ["12.35$","40,30$"]) // you paid 12.35$ of 40,30$.
mozead1996, [email protected]
JSONContentManager is available under the MIT license. See the LICENSE file for more info.