Getting a single value from a JSON object using JSONPath

后端 未结 3 1414
礼貌的吻别
礼貌的吻别 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条回答
  •  萌比男神i
    2020-12-16 10:37

    I think, it depends of language implementation.

    For example in nodejs there is a npm module : https://www.npmjs.com/package/jsonpath

    Which have a method called value, which does exactly what we need

    jp.value(obj, pathExpression[, newValue])

    Returns the value of the first element matching pathExpression. If newValue is provided, sets the value of the first matching element and returns the new value.

    I tried it and worked!

提交回复
热议问题