Coder Social home page Coder Social logo

jsonserializerswift's People

Contributors

comchangs avatar frankfle avatar mborkow avatar mborkow-ebay avatar peheje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonserializerswift's Issues

Suggestion : add json styler/pretifier function too.

//1. convert string to NSData
let jsonData = json.dataUsingEncoding(NSUTF8StringEncoding)!

//2. convert JSON data to JSON object
let jsonObject:AnyObject = try! NSJSONSerialization.JSONObjectWithData(jsonData, options: [])

//3. convert back to JSON data by setting .PrettyPrinted option
let prettyJsonData = try! NSJSONSerialization.dataWithJSONObject(jsonObject, options: .PrettyPrinted)

//4. convert NSData back to NSString (use NSString init for convenience), later you can convert to String.
let prettyPrintedJson = NSString(data: prettyJsonData, encoding: NSUTF8StringEncoding)!

return prettyPrintedJson as String

Optional doubles precision

Optional doubles such as:
var d: Double? = 2.2

Is serialized as
"d: 2.2000000000000002"
Probably because removing the optional part is implemented by parsing the double to a string beforehand (I don't see a way to force unwrap a value of type "Any" aka "Protocol<>").

Missing Dependency Manager

Hi @peheje It would be great of you if you host this on the Dependency Managing Tools. Since everyone in the industry tries to keep the third party lib as dependencies. So, hosting it in Cocoa Pods, Carthage should suffice.

Array of custom objects mapping

Hello
Trying out your job, and getting json like this: "route": {"[0]": {"lat": 37.34520782, "lon": -122.0960117}, "[1]": {"lat": 37.34520782, "lon": -122.0960117}"
How could I remove these "[0]" indexes? And just leave objects {"lat": 37.34520782, "lon": -122.0960117}
Thank you

Getting \ in .toJson() result

hello. I tested this class and I got some odd results.
I tested using a class to transform it to a json string then get the dictionary for it.

so lets say:

class Cat {
 var name: String?
 var color: String?
 var age: String?
 var location: Location
}

struct Location{
 var latitude: Int
 var longitude: Int
}

let cat = Cat()
cat.name = "Mr. Cat"
cat.color = "Orange"
cat.age = "3"
cat.location.longitude = 29.393
cat.location.latitude = -75.762523

let jsonString = JSONSerializer.toJson(cat)

print(jsonString)

the output is :
{"name":"Mr. Cat", "color":"Orange", "age":"3", "location":appName.Location(latitude: 29.393, longitude: -75.762523)}

I dont know why the var location is printed this why just because its a struct or a embeded class.

Multi-dimentional Arrays

Hi @peheje,

I added this to my local to handle Multi-dimentional Arrays.

else if let array = value as? [[Any]] {
                handledValue += "["
                for (index, value) in array.enumerated() {
                    handledValue += "\(value)"
                    handledValue += (index < array.count-1 ? ", " : "")
                }
                handledValue += "]"
            }

Ability to exclude null values in JSON from model object

Hi,

First of thanks a lot for such an effort to build extremely useful library. It is indeed a very helpful.

This is a feature request. Can you please include one property to configure exclusion of Null properties from model object while creating the JSON string.

Let me know if I can be of any help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.