Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Jackson Json Library

json

  • Please log in to reply
4 replies to this topic

#1 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 27 June 2012 - 10:13 AM

To start off let me say that this is related to another post I have open, check here if you are interested, but I digress. My problem is that I'm needing to send complex objects to and from a servlet. So after some googling about RESTful APIs I have stumbled a potential solution, JSONs. After some more searching I've ran across Jackson a java JSON library, but my concern at this point is if I use this library to parse the JSONs and to create them how will I be able to specify the format such that someone not using this library can also create and read valid jsons? Has anyone used this library?
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 27 June 2012 - 10:40 AM

JSON -- is simply a hierarchical notation where each object is a collection of key-object pairs. Simply few types represent everything in JSON - bool (true/false), number, string (double/single quoted) and empty (null). And, as this is as simple, any platforms/applications/tools can read (with using a 3'rd party library or just writing its own code) JSON which follow those simple rules. But, I think your point is that, if you create a string data (e.g. Gulshan, Dhaka - 1212, Bangladesh) from 'address' object of a class from your object oriented language, and send this data to another tools/applications, then to create similar object as your in receivers side, yes those tools/applications need to be aware of such knowledge about which parts represents what in that address string (i.e. need know what which part is house number, which part is street number and such).
  • 0

#3 tpPacino

tpPacino

    CC Regular

  • Member
  • PipPipPip
  • 29 posts
  • Location:Sarajevo, Bosnia and Herzegovina
  • Programming Language:C, Java, C++, PHP, (Visual) Basic, PL/SQL, Pascal, Others
  • Learning:Objective-C, C#, JavaScript, Ruby, Haskell, Others

Posted 27 June 2012 - 10:44 AM

I've read your first topic, and, unfortunately I had never used "Quartz Scheduler".
I have, actually used the JSON library some time ago...
First of all you should read about JSON.
You can read the parsed files in Notepad and even Wordpad(Mozila Firefox uses it) and it will output simple text. But unfortunately you cannot use the text as data which you got from the file without the JSON library. It doesn't matter which JSON type they are (Jackson, JasonML etc...), you can read them with any of these types, because they all use the JSON standard. That will not make any problems, because there is a JSON library for every popular language out there.
Kernelcoder has explained how they work... :)
  • 0

#4 mctim

mctim

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 27 June 2012 - 01:03 PM

the thing that I'm worried about is this if i send the servlet a request like this "object_name = {some json}." How can I be certain that the library, and my servlet, will effectively be able to actually build the object?

This is probably a more library specific question, but can jackson support building JSON's from maps? More specifically let me specify the key and then value in a map from which it would construct a JSON.
  • 0

#5 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 27 June 2012 - 07:55 PM

This is probably a more library specific question, but can jackson support building JSON's from maps? More specifically let me specify the key and then value in a map from which it would construct a JSON.

As I said, its upto you about how you want to represent/package your 'Map Related Object' into JSON and send it to other end. And then on the other side, you need to parse the representation/package from JSON and construct your object accordingly.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download