last day (15 days later) » 

3:57 AM
2
A: JSONSerialization parsing issue:

dahiya_boyYou can directly use below model class, reference : http://www.jsoncafe.com/ class OperationModel : NSObject, NSCoding{ var hoursOfOperation : HoursOfOperation! /** * Instantiate the instance using the passed dictionary values to set the properties values */ init(fromDic...

 
Thanks a a lot.. i'm done with Json Parsing .Can you help me sending the same to API . How can we achieve the same with this model?
That is same structure as described above i.e. json with few additional keys and values . But if I send it as it is , it gives me - "invalid json"
 
@Preetika Hit your API in postman with proper params (if any). Use this data to create model.
P.S. You can validate your json from formatter.
@Preetika If you still facing issue then give me gist of your APi, I will surly check for you.
 
Hey @dahiya_boy - Thanks for the support. I have shared my main class : gist.github.com/PreetikaSingh/f0a2c5884ac39d0988a4cbd723b7bb‌​d7
Please see the RootClass.swift - AddActivityToRequest method that I used to send the params. Params created here are not being JSONStringify serialized.
 
4:36 AM
I need to see your json. Till then I cant say anything.
 
4:46 AM
Can you clear me one thing, Are you creating model from the json or you sending data from post api by creating the model ?? These two different things. In first, you getting data from API and in second, you sending data to server with POST API.
 
yes Im receiving data from an Api and have to send the same to another API adding on some params
{
"isDeleted" : 0,
"typicalCostPG" : 0,
"status" : 1,
"title" : "\"The bow and arrow is my weapon\"",
"creator" : {
"username" : "OfficialDowoodle",
"id" : "accd5812-3934-11e6-9e03-fa2d2f001a34",
"profilepictureurl" : {
"avatar" : "https:\/\/s3-us-west-2.amazonaws.com\/dowoodle-images\/users\/accd5812-3934-11e6-9e03-fa2d2f001a34.png?v=4540667.02236438",
"value" : 0
},
"state" : 1
},
"tags" : "archery,movietheme, hungergames, competitive,",
"image" : {
"originImg" : "https:\/\/s3-us-west-2.amazonaws.com\/dowoodle-images\/staging\/testActivity\/8d939160-870a-11e6-92a8-cd3028627816.jpg",
This is complete json
 
So what is the issue point?
Are you able to create model successfully ??
 
5:02 AM
yes , I created model. But when I use AddActivityToRequest method in RootClass.swift in the shared gist and prepare params, they are not json Serialized and I get deserialization error
 
Bcz AddActivityToRequest is not in API data.
 
API data ?
 
If your model is working proper with the json (assuming when you created the model, your api have full response means not any array or dict is empty and it covers all the keys) then pls dont edit util there is no change in API.
API data means your API response i.e. json data.
 
The model works properly , I created them from jsonCafe.com and parsing goes quite well, but when I create parameters from the AddActivityToRequest.toRequestParameters and convert this to JSONString, It does not validate json
 
How you getting AddActivityToRequest data as it is not in the Json you mentioned above.
 
5:20 AM
Please see the gist gist.github.com/PreetikaSingh/f0a2c5884ac39d0988a4cbd723b7bb‌​d7 - RootClass.Swift - method - AddActivityToRequest
 
5:49 AM
If you wanted to send this values to server then send directly, no need to create model. No need to create AddActivityToRequest.
You model must have the same structure as like your json structure else data will not bind properly.
Hope now you will be cleared.
 

last day (15 days later) »