iOS String Converting to JSON - json

I am a noob at this and I apologize for the simple question but I looked everywhere and have not found any answers to my problem. Is there any way to parse a string in iOS to JSON? Particularly for the iPhone.
So far I have managed to download the JSON API for iPhone and parsed JSON. But that is as far as I got.
I apologize for my english if I sound vague or not straight to the point.

TouchJSON is available # https://github.com/stig/json-framework/
Use TouchJSON Writer class to create JSON File as using this class JSON can be created from dictionary and array.

Related

Flutter parsing json with json_serializable

I am a beginner in dart/flutter programming and I could use some help with using the json_serializable plugin:
I´ve set everything up according to this tutorial: https://flutter.io/json/
but the one thing that is never mentioned is how to load the .json file into a JSON string for the .decode method in the end.
I´ve seen a lot of people using an async function to load it, but I can´t get it to work and another question I have is how does the json_serializable load it? According to my research (https://pub.dartlang.org/packages/json_serializable) it produces a Dart field with the contents of a file containing JSON. Is it possible to also use this in the .decode method?
Would be great if someone could give me answers to my questions.

How do I convert the following data serialization format into POJO or JSON?

I was expecting a JSON string while testing an API using Postman, but instead got this:
{city=Shanghai, work=112-454-7895, fax=788-899-7899}
Obviously I cannot put that into Google and ask what format is it, hence I am asking it here. Postman also says it is a 'bad string'.
I have never seen the above data serialization format. If someone can point the format out to me I would be able to find and use a converter. Additional suggestion with converting it to POJO or JSON are welcome as well.
I figured out that the above format is a stringified version of a HashMap<String, String>, and that there is no direct way to convert it into JSON/POJO. Converting it into json string requires additional work but is fairly straightforward.

How does JSON work when calling from Postman (or SoapUI)?

I'm using Postman and sending various requests that get responses in XML or JSON. I want to understand how JSON works with the APIs. I know that JSON is a called response and I know how to write a JSON file and read it and understand it, although I've never actually used it.
So, my question is how does JSON show up on the website?
I imagine someone has to code it there, similar to HTML.
When I google, I just basically get how-to instructions on various tools from a procedural standpoint and nothing relevant to my question.

Grails - Error saving JSONObject to MongoDB

I am having trouble saving a JSONObject to a MongoDB database using the MongoDB plugin.
I receive the message:
Can't find a codec for class org.codehaus.groovy.grails.web.json.JSONObject..
This is very frustrating because I am using the JSON parser to load JSON data but can't persist this JSON data to the MongoDb which should be straightforward.
Is there a built in way to convert a JSONOBject to a normal Map? I've tried casting it using asType( Map ), ( Map ), and even using toString() and thent rying to convert back from string to object. I've seen that other vanilla Java questions involve using Jackson but I'm hoping there is a Groovier way to do this rather than importing a whole new library for just two lines of code.
This is what I'm doing for now:
Converting the JSONObject to a string and then using com.mongodb.util.JSON.parse() to convert that string to a DBObject that Mongo can use.
It's not the best but it works for now.
I'm not going to accept this answer because I don't think it's the right answer.
Not saying this is the correct answer, but I was able to convert the JSONObject to a HashMap. For my situation I had a Domain object with an ArrayList (converted from JSONArray by a previous JSONTranslationService) and I was able to convert each of the internal JSONObjects using something like this:
static final UNMARSHAL = { thing ->
thing.objects.collect {
it as Hashmap
}
}
I'm only experiencing this issue after an upgrade from mongodb:3.0.2 to 6.1.2 to support MongoDB 3.4. Are you also running this version of the plugin? If so, I think it's fair to say that there's either a bug in the plugin (I'm already aware of one) or something changed with the default behavior and wasn't documented.

nsjsonserialization in ios5?

I have been reading that there is a now library in ios 5 that allows you to serialize & deserialize JSON data. I can't for the life of me find examples or the framework in my /Developer folder. Anyone have luck locating/working with this? If so could you please point me in the right direction?
NSJSONSerialization is now public in iOS 5, and there's an example of its use in the Tweeting sample app.
I'm using it and it's quite simple, just import the library:
#import <Foundation/NSJSONSerialization.h>
and begin to use it.
Here there's a small but good tutorial: http://pragprog.com/magazines/2011-11/inside-ios-
It is actually part of the Foundation framework, been trying to use it since last night and for the purpose of actually serializing a dictionary to a JSON representation it works quite fine. Sadly I've not tested it the other way around.
Trust me the doc is there and it is no private API, sadly as you observed there are no examples.
I stumbled across iOS5 JSON support in this tutorial, which is part of an excellent series of iOS5 tutorials.
Now iOS5 itself has the ability to serialize and de-serialize the json objects, it will manage all the process behind the scene, and you will be getting easily customizable foundation objects (NSArray,NSDictionary,NSString...) Based on your flavor you represented. As brainjam suggest This is the good tutorial to begin with. Hope your fingers can play around with json objects easily.
Using following simple code you can convert web data into JSON .
In this code "webData" is the data you get when you hit web service.
NSError *jsonParsingError = nil;
NSArray *result=[NSJSONSerialization JSONObjectWithData:webData options:0 error:&jsonParsingError];