简体   繁体   中英

Object mapper from and to json

I am developing an application system that has multiple executable applications on different platforms (java and .net).

For communication between them I am using JSON format. So I need to map object to and from json very frequently. Current solution (seems workaround) is jackson at java end and Newtonsoft.Json at .NET end. Problem is property name are not same and not all properties will be required at de-serialization end

So my questions are:

1. Is there any mapper to do this. Currently using NewtonSoft.JSON.DatasetMapper at .Net end and jsonanysetter annotation at java, but in this approach mapping definition is loaded for each object as actual object mapping code is in code. For example:

  //C#
  myobj.prop1 = dataSet.Tables[0].Rows[0]["propertyName1"].ToString();
  // and so on.....

  //Java
  switch(key)
  {
      case "prop1":
             myobj.setPropery1(value.toString());
             break;
      //and so on......
  }

2. Object transformationRate needs to be very high as object are sent and recieved at very high speed. say some 10k objects per second.

We used GSON in one of our project , i think this reference may help you, Apart from it ,there is a similar question may help you. another q/a in stackoverflow

You should take a look at Jackson. It's the de facto JSON library for Java and will happily handle turning objects into JSON and back again. It has many options to allow you to alter the output, and most per-object configuration is carried out using annotations so is visible in your model rather than hidden away in a separate configuration file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM