daltoniam / jsonjoy-swift Goto Github PK
View Code? Open in Web Editor NEWConvert JSON to Swift objects.
License: Apache License 2.0
Convert JSON to Swift objects.
License: Apache License 2.0
Hi,
with version 2.1.0 I am unable to use the framework as for example
jsonDecoder["MyKey"].getString()
fails, as there is one getString() that throws and one that returns an optional.
EDIT: This is also true for getInt()
etc.
Best regards
Hi! I am also working on this problem on a project called quicktype and wanted to know if you had any interest in joining forces? Check it out:
We only support Swift 4 Codable at the moment (we had Swift 3 support but removed it). We don't have Objective-C support, but we have a module backend supporting multiple languages, so we can share the frontend and type inference stages. Please check it out and let me know if you're interested!
"open var bool: Bool" is broken on XCode 8.1
The underlying json parsing library is now returning the Bool type when parsing my server bool responses. Simple fix, I made this small change locally as a workaround:
///treat the value as a bool
open var bool: Bool {
if let val = self.value as? Bool {
return val
} else if let str = self.string {
let lower = str.lowercased()
if lower == "true" || Int(lower) > 0 {
return true
}
} else if let num = self.integer {
return num > 0
} else if let num = self.double {
return num > 0.99
} else if let num = self.float {
return num > 0.99
}
return false
}
Hi, I have the following JSONDecoder:
Optional({
AppUserId = "JSONJoy.JSONDecoder";
ContentToDisplay = "JSONJoy.JSONDecoder";
CreationDate = "JSONJoy.JSONDecoder";
ExiprationDate = "JSONJoy.JSONDecoder";
IsSeenByUser = "JSONJoy.JSONDecoder";
NotificationContent = "JSONJoy.JSONDecoder";
NotificationID = "JSONJoy.JSONDecoder";
NotificationType = "JSONJoy.JSONDecoder";
SISUserID = "JSONJoy.JSONDecoder";
SISUserNumber = "JSONJoy.JSONDecoder";
})
All keys return a value except for "NotificationContent" it returns another JSON. I was able to get all values by using: decoder["AppUserID"] for example, but for NotificationContent I had to read it as String, convert it to NSData then decode it using JSONDecoder, using decoder["NotificationContent"] just didn't work. Below is my full code, it would be great if you let me know what I'm doing wrong
let resultDecoder = JSONDecoder(response)[resultKey];
let serverResponse = ServerResponseModel(resultDecoder);
if serverResponse.Result == 0 {
var resultArray: Array<JSONDecoder>? = resultDecoder["OperationData"].array;
if let arr = resultArray {
for i in arr {
let jsonNotificationType = i["NotificationType"].integer!;
let jsonMessage: JSONDecoder = i["NotificationContent"]; // This did not work, it was treated like i["NotificationContent"] value was sent as a String and not NSData (if you recall my last issue I provided it's link below the code)
// For some reason we must decode NotificationContenet again like shown below
let x = (i["NotificationContent"].string! as NSString).dataUsingEncoding(NSUTF8StringEncoding);
switch jsonNotificationType{
case 0:
let messageModel = MessageModel(JSONDecoder(x!));
break;
}
}
For various purposes I think JSONJoy would greatly benefit from having the ability to return a JSON String (ie let jsonString: String = myObject.getJSONString()
)
Where do i put the json file?
What if you're getting a response of just an array, no keys. for example...
[
{
"SecureString" : "this is a string"
},
{
"SecureString" : "this is another string"
}
]
How can JSONJoy handle that?
JSONJoy.m:76:38: Too many arguments to function call, expected 0, have 2
I miss the i
in dictionary.
Got this error with my code, i imported JSONJoy.xcodeproj and added to Build Phrase
struct Article : JSONJoy {
var id: String?
var date: NSDate?
var title: String?
var body: String?
init() {
}
}
CMD + Left Click "import JSONJoy"
import Foundation
import JSONJoy
import UIKit
//
// JSONJoy.h
// JSONJoy
//
// Created by Austin Cherry on 9/24/14.
// Copyright (c) 2014 Vluxe. All rights reserved.
//
//! Project version number for JSONJoy.
var JSONJoyVersionNumber: Double
seems no any class or prototype in framework.
if lower == "true" || lower.toInt() > 0 {
swift 2.0 : toInt() method is given a error. Because,In Swift 2.x, the .toInt() function was removed from String
Hi!
I've used your library via CocoaPods and faced a problem with adding of new types via extension mechanism: since variable "value" is not public, it is impossible to write an extension(for example, for UInt64 support):
public extension JSONDecoder {
public var unsignedLong: UInt64? {
return (value as? NSNumber)?.unsignedLongLongValue
}
}
because "value" is an internal field of the JSONDecoder class and is available only inside it's module.
Is there any way to print/debug json payload? It would be nice to have such functionality in JSONDecoder
I am using JSONJoy and SwiftHTTP, both are awesome, thanks!
Everything works great when using SwiftHTTP to create a local account (ie not using FB). However when using facebook login, the JSON object returns slightly different keys
For example, our local API returns firstName : Travis
FB returns first_name : Travis
I would like to use the same User model if possible and was wondering if there is a way I can assign firstName
to either decoder["firstName"].string
or decoder["first_name"].string
depending on if I sent the local User object or the FB user object.
Cheers,
-Travis
can you help me please?
In README.md, Array and Dictionary support. I use second option to embed objects but at
for address in decoder["addresses"].array ... it get error "Could not find member 'array' ".
How to fix it? (with xcode 6)
I have an object that contains an array of objects, in this case hosts
and consels
.
Below is some code, can I get a little assistance as I haven't found an example of this type of usage of JSONJoy
Settings.swift
let latitude: Double
let longitude: Double
var distance: Float
let black: Int
let white: Int
let hosts: Hosts
init()
{
latitude = 0
longitude = 0
distance = 0
black = 0
white = 0
hosts = Hosts()
}
init(_ decoder: JSONDecoder) {
latitude = decoder["home_lat"].double!
longitude = decoder["home_lng"].double!
distance = decoder["distance"].float!
black = decoder["black"].integer!
white = decoder["white"].integer!
}
Hosts.swift
import JSONJoy
struct Hosts : JSONJoy {
var hosts: Array<Host>
init() {
hosts = Array<Host>()
}
init(_ decoder: JSONDecoder) {
hosts = Array<Host>()
//we check if the array is valid then alloc our array and loop through it, creating the new address objects.
if let conns = decoder.array {
for hostDecoder in conns {
hosts.append(Host(hostDecoder))
}
}
}
}
struct Host : JSONJoy {
var state: String
var packageDirection: String
var purpose: String
var proto: String
var destinationPort: String?
var sourcePort: String?
var classType: String?
init(_ decoder: JSONDecoder) {
self.state = decoder["state"].string!
self.packageDirection = decoder["pack1dir"].string!
self.purpose = decoder["purpose"].string!
self.proto = decoder["proto"].string!
self.destinationPort = decoder["dport"].string
self.sourcePort = decoder["sport"].string
self.classType = decoder["class"].string
}
}
Example JSON:
{
black: 20,
white: 80,
home_lat: 38.167606,
home_lng: -85.304797,
distance: 905,
hosts: [
{
ip: 1236274589,
handle: "1",
quality: 100,
lat: 40,
lng: -85
},
{
ip: 1270515439,
handle: "",
quality: 1,
lat: 39,
lng: -84
},
{
ip: 1676608305,
handle: "",
quality: 2,
lat: 44,
lng: -79
},
{
ip: -822148318,
handle: "",
quality: 1,
lat: 32,
lng: -95
},
{
ip: 1546188984,
handle: "",
quality: 89,
lat: 51,
lng: 0
},
{
ip: 418662793,
handle: "",
quality: 92,
lat: 54,
lng: -128
},
{
ip: 1259536675,
handle: "lumb3r",
quality: 83,
lat: 32,
lng: -97
},
{
ip: 1656966568,
handle: "Vextiles",
quality: 100,
lat: 29,
lng: -95
},
{
ip: 1756634330,
handle: "Legion",
quality: 86,
lat: 38,
lng: -97
},
{
ip: 1817750167,
handle: "JACK",
quality: 0,
lat: 42,
lng: -83
},
{
ip: 850914650,
handle: "matt",
quality: 0,
lat: 38,
lng: -105
},
{
ip: 1287191577,
handle: "beyondr",
quality: 0,
lat: 33,
lng: -97
},
{
ip: 1808987642,
handle: "graveyard",
quality: 0,
lat: 30,
lng: -90
},
{
ip: 1678277474,
handle: "jimmy",
quality: 0,
lat: 38,
lng: -97
},
{
ip: 1678273633,
handle: "etheric",
quality: 0,
lat: 38,
lng: -97
},
{
ip: 1247978822,
handle: "Freytos",
quality: 0,
lat: 36,
lng: -76
},
{
ip: 1633640910,
handle: "iBgoods",
quality: 0,
lat: 43,
lng: -85
},
{
ip: 844984152,
handle: "phantom",
quality: 0,
lat: 43,
lng: -79
},
{
ip: 1269746077,
handle: "captin malboro",
quality: 100,
lat: 33,
lng: -112
}
],
consel: [
{
enabled: false,
connections: [
{
state: "NEW",
pack1dir: "in",
purpose: "g",
dport: "1024:65535",
proto: "udp"
},
{
state: "NEW",
proto: "udp",
purpose: "g",
sport: "1024:65535",
pack1dir: "in"
},
{
pack1dir: "either",
purpose: "g",
class: "0",
proto: "udp",
dport: "1024:65535"
},
{
pack1dir: "either",
purpose: "g",
class: "0",
sport: "1024:65535",
proto: "udp"
}
],
name: "Xbox live",
id: 1,
mac: "50:1A:C5:89:12:FB"
},
{
enabled: false,
connections: [
{
state: "NEW",
proto: "udp",
purpose: "g",
sport: "10000:65535",
pack1dir: "either"
}
],
name: "Wii Online",
id: 2,
mac: "80:19:34:71:0D:31"
}
],
strict_mode: true,
pingass: 22
}
how to do ? object to jsonstr
Hi daltoniam, you specified that your library works in iOS 7.0, but it is specified as 8.0 minimum requirement in cocoapod. Is there limitation in 7.0 ?
Using CocoaPods 0.36.0.beta.1 the:
import JSONJoy
needs to be replaced with:
import JSONJoy_Swift
Probably the new module_name attribute in Podspec can help fixing this.
I am trying to figure out how to parse an array of an array of coordinates, and have tried going through the section on arrays in the read me with no luck. Below is the code that I have for a TripInfo object, which works great minus the polyline array.
required public init(_ decoder: JSONDecoder){
if let hasUserID = decoder["userID"].string{
userID = hasUserID
}
if let hasId = decoder["_id"].string{
id = hasId
}
if let hasPhonePickup = decoder["phonePickupCount"].double{
phonePickup = hasPhonePickup
}
if let hasRapidAccel = decoder["rapidAccelerationCount"].double{
rapidAccel = hasRapidAccel
}
if let hasHardBrake = decoder["hardBrakeCount"].double {
hardBrake = hasHardBrake
}
if let hasAttentionRate = decoder["attentionRate"].double {
attentionRate = hasAttentionRate
}
if let poly = decoder["polyline"].array {
println("POLY COUNT \(poly.count)")
var polylines = [AnyObject]()
for polyDecoder in poly {
println("POLY DECODER \(Polyline(polyDecoder))")
polylines.append(Polyline(polyDecoder))
}
polyline = polylines
}
if let hasScore = decoder["score"].double {
score = hasScore
}
if let hasDistance = decoder["distanceTraveled"].double {
distance = hasDistance
}
if let hasAnswered = decoder["answeredCallCount"].double{
answeredCallCount = hasAnswered
}
I have tried creating a Polyline class for the decoder, but I don't feel like it's the correct way to do it:
class Polyline: JSONJoy{
var coord:[AnyObject]?
required init(_ decoder: JSONDecoder) {
coord = decoder.array
}
}
Here is what the JSON structure is for the polyline that I am wanting to parse:
"polyline": [
[
37.53833374,
-122.36442556
],
[
37.53860477,
-122.36458146
],
[
37.53886398,
-122.36474189
],
[
37.53913555,
-122.36490978
],
[
37.53940264,
-122.36507608
],
[
37.53966646,
-122.3652386
],
[
37.5399271,
-122.36539895
]
],
What is the best way to go about parsing this data?
Hi, I'm using SwiftHTTP to get a JSON response from a WCF REST Service, the json response is as follows:
"{"LoginResult":{"AppUserInformation":{"FirstName":"omar","LastName":"bizreh","UserID":"d157d366-fec8-4d9e-a71e-12539d5e47df","Email":"[email protected]"},"ChildrenAccounts":[{"FullName":"Ahmad Bizreh","PersonID":"b6bc1eba-2dff-437c-bb98-56d0aa768b87","SISNumber":"7001-500111"},{"FullName":"Shadi Bizreh","PersonID":"4c26c2a6-1e81-417f-9f62-b77350ebf387","SISNumber":"7001-500112"},{"FullName":"Rami Bizreh","PersonID":"0aeb1d2f-a6d8-4ecc-a139-fe64afb19617","SISNumber":"7001-500121"}],"Result":0,"SISUserInformation":[{"FirstName":"Omar","LastName":"Bizreh","UserID":"87b145a6-72a2-4a02-adf0-df841dc9a3d1","AccountType":"fe19da29-2ee3-439d-b2b3-edab755fce0b","Password":"123456","SISUserNumber":"7001-5001","SchoolID":"d9cd4a51-91ce-4734-a048-4392921354db","Username":"7001-50011"},{"FirstName":"Omar","LastName":"Bizreh","UserID":"b3a670ac-cee0-422f-9f80-6d62e3643820","AccountType":"fe19da29-2ee3-439d-b2b3-edab755fce0b","Password":"123456","SISUserNumber":"7001-50012","SchoolID":"d9cd4a51-91ce-4734-a048-4392921354db","Username":"7001-50012"}]}}"
As you can see the json that matches your example in the readme, is presented as value for key LoginResult, how do I parse this with JSONJoy?
The response is formatted as follows:
LoginResult:
In your samples I understood how to parse the response if it wasn't presented as value for a key (in my case LoginResult).
Any help would be great.
Thank you.
Hi Dalton,
This is a great tool. Thanks.
I encountered a scenario.
String? can use getOptional() to obtain string
[String]? will result in nil
How to resolve? Or did I miss something.
Flowing the instructions I am getting an error about missing the .append function
import Cocoa
struct Status_response :JSONJoy {
var status: String?
var issu: Issues?
init(){}
init(_ decoder: JSONDecoder){
status = decoder["status"].string
issu = Issues(decoder["issues"])
}
}
struct Issues:JSONJoy {
var issues: Array<Issue>?
init(){}
init(_ decoder: JSONDecoder){
//we check if the array is valid then alloc our array and loop through it, creating the new address objects.
if let issu = decoder["issues"].array {
issues = Array<Issue>()
for issuDecoder in issu {
issues += Issue(issuDecoder)
}
}
}
}
struct Issue:JSONJoy {
var id: Int?
var skill_name : String?
var problem : String?
var priority : Int?
init(){}
init(_ decoder: JSONDecoder){
id = decoder["id"].integer
skill_name = decoder["skill_name"].string
problem = decoder["problem"].string
priority = decoder["priority"].integer
}
}
Hi, I've updated xCode to 9 and at the first build appear the error:
'JSONDecoder' is ambiguous for type lookup in this context
xCode find two JSONDecoder, one in Foundation and one in JSONJoy.
How can I solve it?
JSONJoy.JSONDecoder not works :(
Thanks in advance
I'm reading JSON from a server. A key in the decoder has a possibility to be either an integer or a JSON null. I'd like for it to easily be turned into a Swift Int?. Here's how I handle that, in an extension:
public func getIntOptional() throws -> Int? {
if isNull() {return nil}
guard let i = integer else {throw JSONError.WrongType}
return i
}
public func isNull() -> Bool {
if let raw = rawValue {
if let rawNS = raw as? NSObject {
if rawNS == NSNull() {
return true
}
}
}
return false
}
This seems kind of clumsy, especially the forced unwrapping and casting. Is there a better way?
Hi, I'd like to use Realm together with JSONJoy.
I don't want to create separate objects for both the libraries. Is it possible somehow to use 1 object for both libs? Since Realm objects are classes that inherit from OBJECT.
class Dog: Object {
dynamic var name = ""
dynamic var age = 0
}
Do you have tips and solutions on this? :)
First of all, thank for your development.
My swift project made in swift 4 version, and JSONJoy 3.0.2 version.
I'm stuck in the error msg when complie. That msg was "Contextual closure type '(_, _) -> _' expects 2 arguments, but 1 was used in closure body"..
so i can't modify ..
the code is
public func getOptional<T: JSONJoy>() -> [T]? {
guard let a = getOptionalArray() else { return nil }
do { return try a.reduce(T) { $0.0 + [try T($0.1)] } }
catch { return nil }
}
decoder.getArray(&scopes) its giving me nil value .....
It would be very nice to have name of property when exception wrongType is fired
else debugging of model would be a pain
also ideally would say something like (exception wrongType for field 'address', 'string' expected', 'int' provided
{
"error": {
"name": "Name invalid",
"password": "Password invalid"
}
}
how to decode this son
Hi can you please help to tell me how to call func array(inout collect: Array?)?
For testing purpose I need to translate a string like "{\"ip\": \"128.74.141.82\"}"
to an object, imitating server's response.
How can it be done?
init(_ decoder: JSONDecoder) {
display_name = decoder["display_name"].string
xcode 8 & swift 3
compiler says 'JSONDecoder' has no member string
how can I fix this?
Hi, I want to use it on watch os, how its possible?
now i got Target 'JSONJoy-Swift' of project 'Pods' was rejected as an implicit dependency for 'JSONJoy.framework' because it doesn't contain platform 'watchsimulator' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
JSONJoy.swift:159:31: 'advance' is unavailable: call the 'advancedBy(n)' method on the index
str.removeAtIndex(advance(str.endIndex, -1))
In case of a NSNull object value, description call returns instead of null.
For example it returns
{ "test": }
instead of
{ "test": null }
With this problem, it's not possible to create a new JSONDecoder from the description:
let desc = jsonDecoder1.description
let nsData = (desc as NSString).dataUsingEncoding(NSUTF8StringEncoding)
let jsonDecoder2 = JSONDecoder(nsData!)
jsonDecoder2 is failed if there is a null value...
In below two functions
/**
get typed Array
of JSONJoy
and have it throw if it doesn't work
*/
public func get<T: JSONJoy>() throws -> [T] {
guard let a = getOptionalArray() else { throw JSONError.wrongType }
return try a.reduce(T) { $0.0 + [try T($0.1)] }
}
/**
get typed `Array` and have it throw if it doesn't work
*/
open func get<T: JSONBasicType>() throws -> [T] {
guard let a = getOptionalArray() else { throw JSONError.wrongType }
return try a.reduce([T]()) { $0.0 + [try $0.1.get()] }
}
In below two return values
return try a.reduce(T) { $0.0 + [try T($0.1)] }
return try a.reduce(T) { $0.0 + [try $0.1.get()] }
Error = "Contextual type for closure argument list expects 1 argument, but 2 were specified".
Update your code respectively.
Hi there!
While trying out this amazing tool I noticed two small, and easy to fix issue:
,
character in addresses JSON array after id (both in user and array example)Should I create a pr or will you handle this?
It would be nice to have a decoder["…"].bool
property:
//convert the value to a bool
public var bool: Bool? {
if let value = self.value as? String
{
return value.lowercaseString == "true"
}
return false
}
Gives this error when trying to follow the instructions in README.
[!] Unable to satisfy the following requirements:
- `JSONJoy-Swift (~> 1.1.0)` required by `Podfile`
The latest release is 1.0.1 and using this version number in podfile solves the issue.
@daltoniam could you please help me out
{
"statusCode": 200,
"statusMessage": "Success",
"data": {
"TotalCount": 3,
"GetHomeHistory": [
{
"GroupType": "3",
"GroupName": "name2",
"MessageId": 1829,
"ConversationId": 46,
"DeliveryTimeStamp": "4/6/2017 4:38:12 AM",
"MessageTranscationId": "3049",
"MessageText": "SGVsbG8=",
"Unread_Message_Count": 24,
"UserId": 69
},
{
"GroupType": "2",
"GroupName": "name2,name1",
"MessageId": 1754,
"ConversationId": 47,
"DeliveryTimeStamp": "3/4/2017 7:01:17 AM",
"MessageTranscationId": "2932",
"MessageText": "UnRncg==",
"Unread_Message_Count": 4,
"UserId": 69
},
{
"GroupType": "1",
"GroupName": "name3",
"MessageId": 1753,
"ConversationId": 49,
"DeliveryTimeStamp": "2/28/2017 10:23:24 AM",
"MessageTranscationId": "2931",
"MessageText": "UnRncg==",
"Unread_Message_Count": 1,
"UserId": 69
}
]
}
}
how to extract the key value of "GetHomeHistory" which is an array of objects
I am doing in the following way
struct HomeModel : JSONJoy {
let status:Int
let message:String
let totalCount: Int
var conversationHistoryArr: [ConversationHistoryModel]? = [ConversationHistoryModel] ()
init(_ decoder: JSONDecoder) throws {
status = try decoder["statusCode"].getInt()
message = try decoder["statusMessage"].getString()
if let respData = decoder["data"].dictionary {
if respData["TotalCount"]?.getInt() != nil {
totalCount = (respData["TotalCount"]?.getInt())!
} else {
totalCount = 0
}
if respData["GetHomeHistory"]?.getArray(&conversationHistoryArr) != nil{
if let homeHistoryData = decoder["GetHomeHistory"].array{
for rsp in homeHistoryData {
let resp = try? ConversationHistoryModel(rsp)
print(resp as Any)
conversationHistoryArr?.append(resp!)
}
}
else{
conversationHistoryArr = [ConversationHistoryModel]()
}
}
}
else{
totalCount = 0
}
}
}
my "ConversationHistoryModel" is as follows
struct ConversationHistoryModel : JSONJoy {
let groupType:String
let groupName:String
let messageId:Int
let conversationId:Int
let messageTime:String
let messageTransactionId:String
let messageText:String
let unreadMessageCount:Int
let userId:Int
init(_ respData: JSONDecoder) throws {
if respData["GroupType"].getString() != nil{
groupType = (respData["GroupType"].getString())!
}
else{
groupType = ""
}
if respData["GroupName"].getString() != nil {
groupName = (respData["GroupName"].getString())!
} else {
groupName = ""
}
if respData["MessageId"].getInt() != nil {
messageId = (respData["MessageId"].getInt())!
} else {
messageId = 0
}
if respData["ConversationId"].getInt() != nil {
conversationId = (respData["ConversationId"].getInt())!
} else {
conversationId = 0
}
if respData["DeliveryTimeStamp"].getString() != nil {
messageTime = (respData["DeliveryTimeStamp"].getString())!
} else {
messageTime = ""
}
if respData["MessageTranscationId"].getString() != nil {
messageTransactionId = (respData["MessageTranscationId"].getString())!
} else {
messageTransactionId = ""
}
if respData["MessageText"].getString() != nil {
messageText = (respData["MessageText"].getString())!
} else {
messageText = ""
}
if respData["Unread_Message_Count"].getInt() != nil {
unreadMessageCount = (respData["Unread_Message_Count"].getInt())!
} else {
unreadMessageCount = 0
}
if respData["UserId"].getInt() != nil {
userId = (respData["UserId"].getInt())!
} else {
userId = 0
}
}
}
Any help is appreciated
JSONJoy.swift:170:20: Immutable value 'str' was never used; consider replacing with '_' or removing it
if let str = self.string {
Super subtle nerdity with the Gandalf's eagles to Mordor theory. Worthy of opening an issue.
Hi Dalton, library is a life-saver, thank you thank you.
Question: I have JSON that looks like this:
{
"userdata": {
"192.168.88.253": {
"applications": {
"54.230.87.156": {
"upbytes": 1055296,
"downbytes": 297264
},
"63.203.87.82": {
"upbytes": 18816,
"downbytes": 18816
},
"63.203.87.92": {
"upbytes": 18816,
"downbytes": 18816
}
}
}
}
}
Before I go and refactor this to be an array.. Is there a way JSONJoy can decode dynamic and meaningful keys like this?
In the above example '192.168.88.253' is a key I can't get to decode since it can be any arbitrary IP address (and there may be 0-infinity passed to JSONJoy).
My code needs access to both the IP, its applications and then for each application another dynamic and meaningful key and then its bytes data.
I could convert these down to just arrays of arrays without meaningful keys but that will create a domino effect of refactoring I'd like to avoid..
Thanks!
Here's what my response handler from swift looks like, my response object is nested in a "data" attribute While I've been able to figure out how to parse arrays, how do I do this for a rather simple object?
var jDecoder = JSONDecoder(response.responseObject!)["data"]
var p = Profile( jDecoder )
all my values in my struct are nil? How do I create a decoder with nested property on my response?
Please provide a sample snippet to parse a array of strings.
Eg.
{
"Places" : [
"Asia",
"Africa",
"America"
]
}
I do not see a straight forward way to parse array of strings like this without a key.Please explain
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.