检查BsonValue类型中是否存在数组

时间:2016-09-22 11:24:49

标签: c#

我有一个BsonValue abc并且正在寻找一种方法来检查它是否包含数组。结构如下:

"abc":[
"key1": "value1",
"key2": "value2",
.
.
"mno":{
"pqr":[
"valuefirst",
"valuesecond"
]
},
.
.
]

在C#代码中,当我尝试检查数组pqr是否存在时 if(abc["mno"]["pqr"] != null),我得到了KeyNotFoundException。如果abcpqr存在mnoabc,则将filter编入索引是错误的。那么,如何检查存储为BsonValue的BsonDocument是否存在这些并克服异常?考虑使用 > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url gitlab@gitlab:group/project.git # timeout=10 Pruning obsolete local branches Fetching upstream changes from gitlab@gitlab:group/project.git > git --version # timeout=10 > git fetch --tags --progress gitlab@gitlab:group/project.git +refs/heads/*:refs/remotes/origin/* --prune ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from gitlab@gitlab:group/project.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1051) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082) at hudson.scm.SCM.checkout(SCM.java:485) at hudson.model.AbstractProject.checkout(AbstractProject.java:1269) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1741) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress gitlab@gitlab:group/project.git +refs/heads/*:refs/remotes/origin/* --prune" returned status code 1: stdout: stderr: remote: Counting objects: 14, done. remote: Compressing objects: 7% (1/14) remote: Compressing objects: 14% (2/14) remote: Compressing objects: 21% (3/14) remote: Compressing objects: 28% (4/14) remote: Compressing objects: 35% (5/14) remote: Compressing objects: 42% (6/14) remote: Compressing objects: 50% (7/14) remote: Compressing objects: 57% (8/14) remote: Compressing objects: 64% (9/14) remote: Compressing objects: 71% (10/14) remote: Compressing objects: 78% (11/14) remote: Compressing objects: 85% (12/14) remote: Compressing objects: 92% (13/14) remote: Compressing objects: 100% (14/14) remote: Compressing objects: 100% (14/14), done. remote: Total 14 (delta 11), reused 0 (delta 0) From gitlab:group/project + 9d4232f...2eb8fcb HEAD -> origin/HEAD (forced update) error: Ref refs/remotes/origin/develop is at 2eb8fcb4a998bab10ee5851a56b61b5fc3b7bec5 but expected 9d4232f08532456b4c69a0307cdc96bd267f12b2 ! 9d4232f..bcdc945 develop -> origin/develop (unable to update local ref) eb750cb..b4d4ce2 master -> origin/master at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1752) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1495) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:795) ... 11 more ERROR: null 。但这适用于 > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url gitlab@gitlab:group/project.git # timeout=10 Pruning obsolete local branches Fetching upstream changes from gitlab@gitlab:group/project.git > git --version # timeout=10 > git fetch --tags --progress gitlab@gitlab:group/project.git +refs/heads/*:refs/remotes/origin/* --prune > git rev-parse origin/develop^{commit} # timeout=10 Checking out Revision 2eb8fcb4a998bab10ee5851a56b61b5fc3b7bec5 (origin/develop) > git config core.sparsecheckout # timeout=10 > git checkout -f 2eb8fcb4a998bab10ee5851a56b61b5fc3b7bec5 > git rev-list 9d4232f08532456b4c69a0307cdc96bd267f12b2 # timeout=10 Set build name. New build name is '#16007-origin/develop-2eb8fcb' [workspace] $ /bin/sh -xe /tmp/hudson5005409752690042196.sh + echo '' + echo '' + /usr/local/bin/prove -j 3 --lib --timer --nocount --formatter=TAP::Formatter::JUnit /var/lib/jenkins/jobs/project/workspace/t Build step 'Execute shell' marked build as failure Set build name. New build name is '#16007-origin/develop-2eb8fcb' Variable with name 'BUILD_DISPLAY_NAME' already exists, current value: '#16007-origin/develop-2eb8fcb', new value: '#16007-origin/develop-2eb8fcb' (如果我错了,请纠正我)。为此做了什么工作?

0 个答案:

没有答案