本文介绍了面对scala.util.parsing.json._包的弃用该使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决Scala问题?我在项目中通过JSON使用情况发出了警告:

How to solve Scala Problem?I have warning by JSON usage in my project:

import scala.util.parsing.json._
JSON.parseRaw("[{'a':'b'},{'c':'d'}]")

推荐答案

通常,这意味着功能已被另一种实现所取代,另一种实现的使用优于旧的实现,而这样的问题仅表示OP太懒了,无法用Google搜索文档.对于Java语言的库而言,尤其如此,因为它非常重视向后兼容性(以至于有些痛苦). Scala生态系统在这方面并不严格,升级到该语言的较新版本意味着您可以获得一个不同的API甚至二进制不兼容.另请参见 Scala:版本之间的二进制不兼容.这不是对Scala的评论.存在这些不兼容的充分原因.

Usually, this means a piece of functionality has been superseded by another implementation the use of which is preferred over the old one and a question like this simply means the OP is too lazy to google the docs. This is especially true in case of libraries in the Java language, which treats backward compatibility very seriously (to the point it becomes a pain for some). The Scala ecosystem is not so strict in this regard and upgrading to a newer version of the language means you can get a different API or even binary incompabilities. See also Scala: binary incompatibility between releases. This is not a comment against Scala. There are good reasons these incompatibilities exist.

但是,我必须承认的.package"rel =" noreferrer>文档不包含有关此功能的建议替代的任何信息.我花了相当长的时间才能找到一些与建议的替代物几乎没有明确表述的东西.

However, I must admit that the documentation for scala.util.parsing.json does not contain any information regarding the recommended replacement for this functionality whatsoever. It took me quite a while to dig up something that just barely resembles a clear statement of what the recommended replacement is.

社区中关于这种弃用的意义和影响似乎进行了很多讨论.我建议阅读在scala-用户组(如果您有兴趣).

There seems to have been a lot of discussion in the community about the point and repercussions of this deprecation. I recommend reading this thread in the scala-users group if you're interested.

这种弃用的最引人注目的原因似乎在于性能和线程安全性较差.

The most quoted reasons for this deprecation seem to be around poor performance and thread safety.

弃用是此Jira问题的一部分,在由于弃用而未能完成的相关任务的结尾注释中,建议使用不同的解析器. /a>.

The deprecation was done as part of this Jira issue and the use of different parsers is recommended in the closing comment of this related task that was not completed due to the deprecation.

替代方法包括:

  • play-json
  • spray-json
  • argonaut
  • jackson
  • rapture-json (which allows you to choose between different implementations)

回答您的问题.这是一个警告,在实际删除此对象之前,您的代码不应中断.但是,如果在此功能中发现了新的错误,则很可能不会修复它们.如果您升级到实际删除了那些软件包的新版本的Scala(版本2.11.0及更高版本,根据文档)

To answer your question. This is a warning, your code should not break until this object is actually removed. However, if new bugs are found in this functionality, they most likely aren't going to be fixed. Your code can also break if you upgrade to a newer version of Scala that actually has those packages removed (Version 2.11.0 and above, according to the documentation)

这篇关于面对scala.util.parsing.json._包的弃用该使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 15:05