English 中文(简体)
B. 将日本特性与明示机构-方案相提并论时的错误控制性质
原标题:Bad control character error when parsing Japanese characters with express body-parser

我把一把一把大的“JSON”str到像这样明确的终点:

import bodyParser from  body-parser ;
const app = express();
const jsonParser = bodyParser.json({ limit:  4mb  });

const databaseUri =  <db connection string> ;
const databaseClient = new MongoClient(databaseUri);

app.use(cors());

app.post( /fillDatabase , jsonParser, async (request, response) => {
    const subjects = request.body;
    console.log(`Filling database with ${subjects.length} subjects`);
    const database = databaseClient.db( wanikani_db );
    const subjectsTable = database.collection( subjects );
    const result = await subjectsTable.insertMany(subjects).then((response) => {
        console.log( inserted   + response.insertedCount +   subjects );
    }).catch(() => {
        console.log( failed to insert subjects );
    }).finally(() => {
        console.log( finally after inserting subjects );
    });
});

当我担任“JSON”号星座时,终点功能将达到完成(见<代码>,在插入“ 日志”后定稿),但请求未完成。 我拿着ack痕。

SyntaxError: Bad control character in string literal in JSON at position 289
    at JSON.parse (<anonymous>)
    at parse (/Users/maxc/Documents/repos/wanikani-flashcards/backend/node_modules/body-parser/lib/types/json.js:92:19)
    at /Users/maxc/Documents/repos/wanikani-flashcards/backend/node_modules/body-parser/lib/read.js:128:18
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at invokeCallback (/Users/maxc/Documents/repos/wanikani-flashcards/backend/node_modules/raw-body/index.js:238:16)
    at done (/Users/maxc/Documents/repos/wanikani-flashcards/backend/node_modules/raw-body/index.js:227:7)
    at IncomingMessage.onEnd (/Users/maxc/Documents/repos/wanikani-flashcards/backend/node_modules/raw-body/index.js:287:7)
    at IncomingMessage.emit (node:events:514:28)
    at endReadableNT (node:internal/streams/readable:1376:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

正在破碎的JSON物体已贴上,。 中断的性质是数据――和;性质。

这里是:

000001c0: 2020 2020 2020 2020 2020 2022 6368 6172             "char
000001d0: 6163 7465 7273 223a 2022 e4b8 8022 2c0a  acters": "...",.

第289号立场的特性是日本的特性。 我如何描述这种性质和其他类似特征?

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签