Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

搜索出JSONObject里面某个value对应的所有PATH #709

Closed
baijian opened this issue Jul 4, 2016 · 4 comments
Closed

搜索出JSONObject里面某个value对应的所有PATH #709

baijian opened this issue Jul 4, 2016 · 4 comments
Milestone

Comments

@baijian
Copy link

baijian commented Jul 4, 2016

一个JSONObject,递归遍历所有的叶子节点值,搜索出某个值对应的所有path返回,希望可以提供对应的方法直接使用.

@wenshao
Copy link
Member

wenshao commented Jul 7, 2016

为什么有这个需求?怎样的一个使用场景?

@wenshao wenshao added this to the 1.2.14 milestone Jul 7, 2016
@baijian
Copy link
Author

baijian commented Jul 7, 2016

类比的业务场景如下:

{
  "name": "test",
  "members": [
    {
       "name": "name1"
       "age": 12,
    },
    {
      "name": "name2",
      "age": 22,
    }
  ],
  "adminMembers" [
   {
       "name": "name3"
       "age": 12,
    },
    {
      "name": "name4",
      "age": 22,
    }
  ],
}

如上的一个json,我用这样的一个json来存储信息,一般情况下我知道path可以找出某个人的age,另外一种场景就是我现在知道一个人的name,想知道他的path,然后也就可以通过path知道这个人的信息以及其他信息了.

@wenshao
Copy link
Member

wenshao commented Jul 12, 2016

已经实现,方法是

public class JSONPath {
    public static Map<String, Object> paths(Object javaObject);
}

看是否符合你的要求

@baijian
Copy link
Author

baijian commented Jul 14, 2016

满足~

@baijian baijian closed this as completed Jul 14, 2016
asa1997 pushed a commit to Be-Secure/fastjson that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants