Skip to content

Commit ecea370

Browse files
committed
check jsonString
1 parent 4b2ae15 commit ecea370

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: src/main/java/us/kbase/userprofile/MongoController.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.mongodb.MongoClientSettings;
2424
import com.mongodb.MongoCredential;
2525
import com.mongodb.ServerAddress;
26-
import org.bson.BsonDocument;
2726
import org.bson.Document;
2827

2928
public class MongoController {
@@ -204,7 +203,8 @@ public void setProfile(UserProfile up) {
204203
Document replacement = new Document("user", user);
205204
if(up.getProfile() != null) {
206205
if(up.getProfile().asJsonNode().isObject()) {
207-
replacement.put("profile", BsonDocument.parse(up.getProfile().asJsonNode().toString()));
206+
System.out.println("jsonString1: " + up.getProfile().asJsonNode().toString());
207+
replacement.put("profile", Document.parse(up.getProfile().asJsonNode().toString()));
208208
} else {
209209
throw new RuntimeException("Profile must be an object if defined.");
210210
}
@@ -223,7 +223,8 @@ public void setProfile(UserProfile up) {
223223
Document profile = new Document("user", user);
224224
if (up.getProfile() != null) {
225225
if (up.getProfile().asJsonNode().isObject()) {
226-
profile.put("profile", BsonDocument.parse(up.getProfile().asJsonNode().toString()));
226+
System.out.println("jsonString2: " + up.getProfile().asJsonNode().toString());
227+
profile.put("profile", Document.parse(up.getProfile().asJsonNode().toString()));
227228
} else {
228229
throw new RuntimeException("Profile must be an object if defined.");
229230
}
@@ -255,7 +256,7 @@ public void updateProfile(UserProfile up) {
255256
Iterator<Entry<String, JsonNode>> fields = profileNode.fields();
256257
while(fields.hasNext()) {
257258
Entry<String,JsonNode> e = fields.next();
258-
update.put("profile." + e.getKey(), BsonDocument.parse(e.getValue().toString()));
259+
update.put("profile." + e.getKey(), Document.parse(e.getValue().toString()));
259260
}
260261
} else {
261262
throw new RuntimeException("Profile must be an object if defined.");
@@ -273,7 +274,7 @@ public void updateProfile(UserProfile up) {
273274
Document profile = new Document("user", user);
274275
if(up.getProfile() != null) {
275276
if(up.getProfile().asJsonNode().isObject()) {
276-
profile.put("profile", BsonDocument.parse(up.getProfile().asJsonNode().toString()));
277+
profile.put("profile", Document.parse(up.getProfile().asJsonNode().toString()));
277278
} else {
278279
throw new RuntimeException("Profile must be an object if defined.");
279280
}

0 commit comments

Comments
 (0)