Comments (5)
I assume that response.json
is the typed content accessor from the example project that returns SwiftyJSON, right?
What's going on here is that at this point:
var res = response.json
//example manipulation
res["cbs"][0]["input"][0]["value"].string = "00000"
…res
is a SwiftyJSON.JSON
object, but NSJSONConvertible
wants a dictionary or array. You have two options:
-
Convert the
JSON
back to anNSDictionary
to pass it to Siesta:api.login.request(.POST, json: res.dictionary)
-
If you're doing that in many places, add a Siesta request flavor that accepts JSON objects:
public func request(method: RequestMethod, jsonDict: JSON) -> Request { return request(method, json: json.dictionary) }
(Warning: untested code there!)
from siesta.
Yes, res is a SwiftyJSON.JSON.
I've already tried with .dictionary
but seems that it generates a non valid type for the method signature:
Argument type '[String : JSON]?' does not conform to expected type 'NSJSONConvertible'
from siesta.
Ah, indeed. Here is some code that I’ve verified actually compiles:
extension Resource
{
public func request(method: RequestMethod, jsonDict: JSON) -> Request
{ return request(method, json: json.object as! NSJSONConvertible) }
}
See if that does the trick.
(Hmm. I should expose FailedRequest
in the public API so you can replace that as!
with an as?
.)
from siesta.
Yes, this is right, but there is a typo in the call: the parameter is called jsonDict, not json :).
extension Resource
{
public func request(method: RequestMethod, jsonDict: JSON) -> Request
{ return request(method, json: jsonDict.object as! NSJSONConvertible) }
}
Thank you for the help.
Do you think that could be useful to add this example in a "Cookbook" page inside Siesta docs?
from siesta.
the parameter is called jsonDict, not json
Ah, right.
I mean to write up a cookbook for 1.0, but am trying to get API details sorted out first.
I may also add a standard SwiftyJSON extension, now that there's an Extensions
folder for such things.
from siesta.
Related Issues (20)
- Possible memory leak in ProgressTracker HOT 13
- tvOS Carthage compilation broken for Xcode 9 HOT 2
- Swift 4.2 + Xcode 10 HOT 5
- Pods/Siesta/Source/Siesta/Support/WeakCache.swift:14:66: 'UIApplicationDidReceiveMemoryWarning' has been renamed to 'UIApplication.didReceiveMemoryWarningNotification' HOT 1
- Pods/Siesta/Source/Siesta/Support/WeakCache.swift:14:42: Type 'NSNotification.Name' has no member 'UIApplication' HOT 1
- Readme 404 link HOT 2
- unexpected duplicate task error for new Xcode build system from Xcode 10 IOS 12.0.1 HOT 1
- How to refresh same web service ?
- Wildcard in PipelineStage.add(_, contentTypes:) doesn't work as expected
- RemoteImageView placeholderImage not showing when imageResource or ImageURL is nil HOT 2
- File-based caching for Siesta HOT 4
- Unexpected version number in 'available' attribute for non-specific platform '*' HOT 2
- Cached Resource timestamp refresh after loading
- Proposal: More elegant way to avoid memory leak in closures HOT 4
- Y'all got wiki-spammed HOT 2
- Chained request progress support
- 404 errors from a resource don't clear as expected from a resource("static url").load()
- Xcode SPM will not accept Quick@around-each dependency HOT 7
- The package product 'Alamofire' requires minimum platform version 10.0 for the tvOS platform, but this target supports 9.0 HOT 3
- Quick dependancy is not correctly versioned HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from siesta.