Differentiate between object and array of objects · Issue #19 · JSONPath-Plus/JSONPath · GitHub
Skip to content

Differentiate between object and array of objects #19

Description

@pradp
var sample1 = {
  "book" : {
    "name" : "book 1",
    "type" : "type 1"
  }
}

var sample2 = {
  "book" : [{
      "name" : "book 1",
      "type" : "type 1"
    }, {
      "name" : "book 2",
      "type" : "type 2"
    }, {
      "name" : "book 3",
      "type" : "type 3"
    }
  ]
}

Can any one help me to construct a single JSON path to extract the book name for which the type = "type 1" from both the samples? The problem is the book can be an array or an object but I can have only one json path to extract the value. Any help would be appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions