I got a scenario.

Required input and output are JSON.

// Input
{
  "OldObject": {
    "Time": 1351160457922,
    "Name": "OName",
    "quantity": 100,
    "price": 10
  }
}


// Output
{
  "NewObject": {
    "Time": 1351160457922,
    "Title": "OName",
    "quantity": 100
  }
}

I need some transformation code or preferably xslt type language to transform json from one format to another. This transformer also need to be fast as transformation will be done on the fly.

Edit
I don't have the definition of the INPUT object received and it might change at run time. but I can use class for OUTPUT object if needed. I have tried to do this as json -> xml -> xslt -> xml -> json, but approximately 1000 objects are received per second at this end and this process might incur overhead.
I can not also use JavaScript as myApp is simple windows based java application and using JavaScript might cause overhead.

推荐答案

试试JOLT.它是一个用Java编写的JSON到JSON转换库.它是在一个将大量JSON从ElasticSearch"后端"转换为前端api的项目上创建的.

For the JSON transform you have listed in your problem, the Jolt "shift" spec would be :

// Jolt "shift" spec
{
    "OldObject": {
        "Time": "NewObject.Time",   
        "Name": "NewObject.Title", // if the input has "OldObject.Name", copy it's value
                                   // to "NewObject.Title
        "quantity": "NewObject.quantity"
    }
}

Json相关问答推荐

使用Powershell脚本将配置信息块添加到json文件

输入请求中不存在null的条件抖动

在T—SQL中将STR_AGG与JSON_ARRAY结合起来

如何获取brew list作为JSON输出

替换字符串中特殊字符的Jolt变换

在Vega中如何通过滑块改变条形图的宽度

用于参考的Jolt变换

当 JSON 字段名称有空格时,ABAP 中的 JSON 反序列化

如何编写 jolt 规范以将不同的对象转换为数组

使用杰克逊解析Kotlin 中的通用密封类

字典和对象的模型创建问题

将 js Array() 转换为 JSON 对象以用于 JQuery .ajax

JBuilder中未定义的局部变量或方法json

如何使用 Newtonsoft.Json 反序列化 JSON 数组

Retrofit 2.0 如何解析嵌套的 JSON 对象?

如何使用 Swift 从 NSURLSession 获取 cookie?

如何获取json格式的KendoGrid显示数据?

Android JSON 库的性能和可用性比较

从 VS 2017 Azure Function 开发中的 local.settings.json 读取值

如何在 postgresql 9.3 中循环 JSON 数组