Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble getting string representation #70

Closed
ChrisBuchholz opened this issue Oct 10, 2014 · 6 comments
Closed

Trouble getting string representation #70

ChrisBuchholz opened this issue Oct 10, 2014 · 6 comments

Comments

@ChrisBuchholz
Copy link

Hi,

I am trying to get the string representation of a JSON object.

Given this example

let json:JSON =  ["I":"am", "a":"json"]
println(json.stringValue)

I expect the println output to be ["I":"am", "a":"json"] but it is nil. I have tried with other input data as well, but with the same result every time. the .string method is the same story.

Is the .string and .stringValue method broken, or am I using them wrong?

This is on the xcode6.1 branch by the way.

@k06a
Copy link
Contributor

k06a commented Oct 11, 2014

You're using them wrong. What you want is .description and .debugDescription

@ChrisBuchholz
Copy link
Author

I'll give their implementation a check later, but the reason I didn't use them initially is because their value, when printed, seems to be "prettified" and I need valid json.

But their might be a difference in their value and their printed value, so I'll give their implementation a check later when I'm at my computer!

@ChrisBuchholz
Copy link
Author

@k06a: .description returns [I: am, a: json] and .debugDescription returns ["I": am, "a": json], neither of which is valid JSON as far as I know.

@k06a
Copy link
Contributor

k06a commented Oct 11, 2014

If you need to serialize json object to data it can be achieved like this: #62

@powerje
Copy link

powerje commented Oct 15, 2014

Looks like #72 might take care of this?

@ChrisBuchholz
Copy link
Author

@k06a: Indeed that is one way to reach the goal.

@powerje: Yes, that looks like a great way to handle this need. Hoping it gets merged into master at some point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants