如何在Ruby on Rails环境中继承java类

时间:2022-05-23 12:00:33

Background: I have a Java application that many programming clients interface with. Recently, a few clients wanted me to develop an API to allow them to inherit my application's Java classes in their Ruby documents without having to change their developing environment to Jruby - they want it to remain Ruby on Rails.

背景:我有一个许多编程客户端与之交互的Java应用程序。最近,一些客户希望我开发一个API,允许他们在Ruby文档中继承我的应用程序的Java类,而不必将他们的开发环境改为Jruby - 他们希望它保留Ruby on Rails。

In this post, it was mentioned that this could be accomplished by using XML or JSON as a middle-man between Java and Ruby on Rails.

在这篇文章中,有人提到这可以通过使用XML或JSON作为Java和Ruby on Rails之间的中间人来实现。

Question: Is the XML/JSON method the best practice? If so, which do you find to be preferable (XML or JSON)? If not, what is a better practice?

问题:XML / JSON方法是最佳实践吗?如果是这样,您认为哪个更适合(XML或JSON)?如果没有,什么是更好的做法?

Once a best practice is determined, some in-depth (as in-depth as you're willing to go) explanation as to how I should approach this would really be helpful.

一旦确定了最佳实践,一些深入的(如您愿意深入的那样)解释我将如何处理这将真正有用。

Thank you so much

非常感谢

1 个解决方案

#1


1  

XML or JSON is really a matter of taste when talking server-level APIs. Both are text formats that can be trasmitted via HTTP, and either one can be consumed by a Rails application.

在谈论服务器级API时,XML或JSON确实是一种品味问题。两者都是可以通过HTTP传输的文本格式,并且Rails应用程序可以使用任何一种格式。

#1


1  

XML or JSON is really a matter of taste when talking server-level APIs. Both are text formats that can be trasmitted via HTTP, and either one can be consumed by a Rails application.

在谈论服务器级API时,XML或JSON确实是一种品味问题。两者都是可以通过HTTP传输的文本格式,并且Rails应用程序可以使用任何一种格式。