Getting a single value from a JSON object using JSONPath

后端 未结 3 1420
礼貌的吻别
礼貌的吻别 2020-12-16 10:19

I have the following JSON and I need to get the plain name value using JSONPath:

{
  \"single\" : {
    \"id\" : 1, 
    \"name\" : \"Item name\         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 10:31

    I was using the Java implementation of JSONPath and got to the very same issue. What worked for me was to add '[0]' to the json path string. So in your case:

    $.single.name[0]

提交回复
热议问题