Extra curly braces when parsing string with Newtonsoft.Json.Linq.JObject











up vote
1
down vote

favorite












I have the following string that I want to parse:



result = "{"faceId":"55717de7-4099-4016-8d72-5c4c9c06fca1","faceRectangle":{"top":316,"left":327,"width":154,"height":154},"faceAttributes":{"smile":0.013,"gender":"female","age":23.0,"facialHair":{"moustache":0.0,"beard":0.0,"sideburns":0.0},"glasses":"Sunglasses"}}"

JObject jsonObject = JObject.parse(result);


This is what the jsonObject becomes:



{{
"faceId": "a2e0c348-c144-4cb7-a7c5-535efabc0482",
"faceRectangle": {
"top": 316,
"left": 327,
"width": 154,
"height": 154
},
"faceAttributes": {
"smile": 0.013,
"gender": "female",
"age": 23.0,
"facialHair": {
"moustache": 0.0,
"beard": 0.0,
"sideburns": 0.0
},
"glasses": "Sunglasses"
}
}}


As you can see above, I suddenly have extra curly braces around the object after parsing. When pasting this into http://json.parser.online.fr/ it returns errors because of these extra braces. Because of the braces, I can't query information from it.



Is there a way that I can get rid of the extra curly braces?










share|improve this question






















  • "I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
    – ADyson
    Nov 8 at 13:00










  • Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
    – ADyson
    Nov 8 at 13:02






  • 1




    Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
    – Brian Rogers
    Nov 8 at 14:58








  • 1




    By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
    – Brian Rogers
    Nov 8 at 15:20










  • Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
    – Hampus Karl Sebastian Rude
    Nov 8 at 16:42















up vote
1
down vote

favorite












I have the following string that I want to parse:



result = "{"faceId":"55717de7-4099-4016-8d72-5c4c9c06fca1","faceRectangle":{"top":316,"left":327,"width":154,"height":154},"faceAttributes":{"smile":0.013,"gender":"female","age":23.0,"facialHair":{"moustache":0.0,"beard":0.0,"sideburns":0.0},"glasses":"Sunglasses"}}"

JObject jsonObject = JObject.parse(result);


This is what the jsonObject becomes:



{{
"faceId": "a2e0c348-c144-4cb7-a7c5-535efabc0482",
"faceRectangle": {
"top": 316,
"left": 327,
"width": 154,
"height": 154
},
"faceAttributes": {
"smile": 0.013,
"gender": "female",
"age": 23.0,
"facialHair": {
"moustache": 0.0,
"beard": 0.0,
"sideburns": 0.0
},
"glasses": "Sunglasses"
}
}}


As you can see above, I suddenly have extra curly braces around the object after parsing. When pasting this into http://json.parser.online.fr/ it returns errors because of these extra braces. Because of the braces, I can't query information from it.



Is there a way that I can get rid of the extra curly braces?










share|improve this question






















  • "I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
    – ADyson
    Nov 8 at 13:00










  • Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
    – ADyson
    Nov 8 at 13:02






  • 1




    Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
    – Brian Rogers
    Nov 8 at 14:58








  • 1




    By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
    – Brian Rogers
    Nov 8 at 15:20










  • Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
    – Hampus Karl Sebastian Rude
    Nov 8 at 16:42













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the following string that I want to parse:



result = "{"faceId":"55717de7-4099-4016-8d72-5c4c9c06fca1","faceRectangle":{"top":316,"left":327,"width":154,"height":154},"faceAttributes":{"smile":0.013,"gender":"female","age":23.0,"facialHair":{"moustache":0.0,"beard":0.0,"sideburns":0.0},"glasses":"Sunglasses"}}"

JObject jsonObject = JObject.parse(result);


This is what the jsonObject becomes:



{{
"faceId": "a2e0c348-c144-4cb7-a7c5-535efabc0482",
"faceRectangle": {
"top": 316,
"left": 327,
"width": 154,
"height": 154
},
"faceAttributes": {
"smile": 0.013,
"gender": "female",
"age": 23.0,
"facialHair": {
"moustache": 0.0,
"beard": 0.0,
"sideburns": 0.0
},
"glasses": "Sunglasses"
}
}}


As you can see above, I suddenly have extra curly braces around the object after parsing. When pasting this into http://json.parser.online.fr/ it returns errors because of these extra braces. Because of the braces, I can't query information from it.



Is there a way that I can get rid of the extra curly braces?










share|improve this question













I have the following string that I want to parse:



result = "{"faceId":"55717de7-4099-4016-8d72-5c4c9c06fca1","faceRectangle":{"top":316,"left":327,"width":154,"height":154},"faceAttributes":{"smile":0.013,"gender":"female","age":23.0,"facialHair":{"moustache":0.0,"beard":0.0,"sideburns":0.0},"glasses":"Sunglasses"}}"

JObject jsonObject = JObject.parse(result);


This is what the jsonObject becomes:



{{
"faceId": "a2e0c348-c144-4cb7-a7c5-535efabc0482",
"faceRectangle": {
"top": 316,
"left": 327,
"width": 154,
"height": 154
},
"faceAttributes": {
"smile": 0.013,
"gender": "female",
"age": 23.0,
"facialHair": {
"moustache": 0.0,
"beard": 0.0,
"sideburns": 0.0
},
"glasses": "Sunglasses"
}
}}


As you can see above, I suddenly have extra curly braces around the object after parsing. When pasting this into http://json.parser.online.fr/ it returns errors because of these extra braces. Because of the braces, I can't query information from it.



Is there a way that I can get rid of the extra curly braces?







json linq json.net






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 12:43









Hampus Karl Sebastian Rude

61




61












  • "I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
    – ADyson
    Nov 8 at 13:00










  • Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
    – ADyson
    Nov 8 at 13:02






  • 1




    Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
    – Brian Rogers
    Nov 8 at 14:58








  • 1




    By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
    – Brian Rogers
    Nov 8 at 15:20










  • Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
    – Hampus Karl Sebastian Rude
    Nov 8 at 16:42


















  • "I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
    – ADyson
    Nov 8 at 13:00










  • Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
    – ADyson
    Nov 8 at 13:02






  • 1




    Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
    – Brian Rogers
    Nov 8 at 14:58








  • 1




    By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
    – Brian Rogers
    Nov 8 at 15:20










  • Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
    – Hampus Karl Sebastian Rude
    Nov 8 at 16:42
















"I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
– ADyson
Nov 8 at 13:00




"I suddenly have extra curly braces around the object after parsing" this makes no sense...where exactly are you seeing this display? When you parse JSON, it becomes an object - code variable representing a data structure. It ceases to be a string of text any more. Any textual representation you're seeing is probably just a function of the debugger, and is largely meaningless - if you want to see it as JSON again you must explicitly serialise it back into a string.
– ADyson
Nov 8 at 13:00












Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
– ADyson
Nov 8 at 13:02




Now, you say "Because of the braces, I can't query information from it"...but you didn't show what code you're writing to query it, or which information exactly you want, or what error / issue you're facing in running your query. Some extra braces shown, probably in a debugger, would have no material impact on that as far as I can see. Please show the actual code which is causing the problem and explain what error you're getting. Then we might be able to offer some practical help. Thanks.
– ADyson
Nov 8 at 13:02




1




1




Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
– Brian Rogers
Nov 8 at 14:58






Are you looking at this value in the debugger? The Visual Studio debugger wraps the results of ToString() calls in curly braces for some reason. To see what value you really have you should output it to the debugger window using Debug.WriteLine, or write it to a file using File.WriteAllText. I bet you will find the extra curly braces suddenly aren't there anymore.
– Brian Rogers
Nov 8 at 14:58






1




1




By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
– Brian Rogers
Nov 8 at 15:20




By the way, here is a fiddle to prove the point: dotnetfiddle.net/p5sJEA
– Brian Rogers
Nov 8 at 15:20












Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
– Hampus Karl Sebastian Rude
Nov 8 at 16:42




Brian thank you, yes that is right! I got the value during debugging in Visual Studio. The problem is solved now!
– Hampus Karl Sebastian Rude
Nov 8 at 16:42

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208001%2fextra-curly-braces-when-parsing-string-with-newtonsoft-json-linq-jobject%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208001%2fextra-curly-braces-when-parsing-string-with-newtonsoft-json-linq-jobject%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff