Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有json,里面有一些对象。我只需要一个来自 json 的对象。那么哪种方法在速度和性能方面会更好——只解析这个对象还是解析整个文档呢?
如果您只想显示可能位于 JSON 对象或 JSON 数组本身的特定 JSON 对象,那么您只需解析该特定 JSON 对象而不是解析整个文档。
如果您不打算使用其余数据,则可以只解析您只需要的项目。
从理论上讲,只有对象会以更少的工作时间更快地为您提供结果。所以只需解析你需要的对象。