我正在尝试反序列化从 Web 服务获得的 JSON 响应。我正在尝试使用 NewtonSoft Json.NET。
我正在尝试解析响应
var results = JArray.Parse(response.Content);
Run Code Online (Sandbox Code Playgroud)
我得到以下异常
Newtonsoft.Json.JsonReaderException 发生 HResult=0x80131500
Message=从 JsonReader 读取 JArray 时出错。当前 JsonReader 项不是数组:StartObject。路径 '',第 1 行,位置 1。Source
=Newtonsoft.Json
我可能需要定义要返回的对象,但不确定如何指定以下响应(对格式感到抱歉,缩进已被编辑器删除):
{"result": [
{
"recordType": "sys_ui_script",
"hits": [],
"tableLabel": "UI Script"
},
{
"recordType": "sys_script",
"hits": [
{
"name": "Approval Events (Non-Task)",
"className": "sys_script",
"tableLabel": "sys_script",
"matches": [ {
"field": "script",
"fieldLabel": "Script",
"lineMatches": [
{
"line": 21,
"context": " updateRecord(current, current.approver.getDisplayValue() + \" rejected the task.\", ",
"escaped": " updateRecord(current, current.approver.getDisplayValue() …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Angular 7应用程序中添加与MongoDB Stich的连接性,但应用程序失败并出现以下错误:
bson.browser.esm.js:453未捕获的ReferenceError:未定义全局
我正在使用Angular 7.2.12并安装了mongodb-stitch-browser-sdk v 4.3.2
我正在使用MongoDB网站上DB Stitch应用程序客户端设置下的代码。
import { Component, OnInit } from '@angular/core';
import { Stitch, RemoteMongoClient, AnonymousCredential} from 'mongodb-stitch-browser-sdk'
@Component({
selector: 'app-alfabetisk',
templateUrl: './alfabetisk.component.html',
styleUrls: ['./alfabetisk.component.css']
})
export class AlfabetiskComponent implements OnInit {
constructor() { }
ngOnInit() {
const client = Stitch.initializeDefaultAppClient('app-id');
}
}
Run Code Online (Sandbox Code Playgroud)
该应用程序在ngOnInit()中失败,并显示以下错误:
bson.browser.esm.js:453未捕获的ReferenceError:在webpack_require(引导程序: 78)位于Module ../ node_modules / mongodb-stitch-core-sdk / dist / esm / index.js(index.js:1)位于webpack_require(bootstrap:78)位于Module ../ node_modules / mongodb-stitch-browser -core / dist / esm / index.js(index.js:1)在webpack_require(bootstrap:78)在Module ../ …