반응형
문자열을 MongoDB BsonDocument로 변환
저는 JSON 형식의 긴 문자열을 가지고 있으며, MongoDB 데이터베이스에 삽입할 수 있도록 BSON 문서로 변환하고 싶습니다.변환은 어떻게 합니까?저는 공식 C# 드라이버를 사용하고 있습니다.
답은 다음과 같습니다.
string json = "{ 'foo' : 'bar' }";
MongoDB.Bson.BsonDocument document
= MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(json);
string json = "{ 'foo' : 'bar' }";
BsonDocument document = BsonDocument.Parse(json);
MongoDB 버전 2.1 사용.NET 라이브러리
string json = "{'foo' : 'bar' }";
var document = new BsonDocument();
document.Add(BsonDocument.Parse(json));
언급URL : https://stackoverflow.com/questions/5624934/convert-string-into-mongodb-bsondocument
반응형
'programing' 카테고리의 다른 글
Python: 목록에 항목 추가 N회 (0) | 2023.05.06 |
---|---|
Git merge는 차이가 있지만 "이미 최신"이라고 보고합니다. (0) | 2023.05.06 |
간단한 Postgre에서 변수를 사용하는 방법SQL 스크립트? (0) | 2023.05.01 |
mongodb에서 "deletemany"와 "remove"의 차이점은 무엇입니까? (0) | 2023.05.01 |
ActivatedRoute의 매개 변수에 따라 구성 요소를 유닛 테스트하는 방법은 무엇입니까? (0) | 2023.05.01 |