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?
json linq json.net
New contributor
add a comment |
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?
json linq json.net
New contributor
"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 ofToString()
calls in curly braces for some reason. To see what value you really have you should output it to the debugger window usingDebug.WriteLine
, or write it to a file usingFile.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
add a comment |
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?
json linq json.net
New contributor
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
json linq json.net
New contributor
New contributor
New contributor
asked Nov 8 at 12:43
Hampus Karl Sebastian Rude
61
61
New contributor
New contributor
"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 ofToString()
calls in curly braces for some reason. To see what value you really have you should output it to the debugger window usingDebug.WriteLine
, or write it to a file usingFile.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
add a comment |
"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 ofToString()
calls in curly braces for some reason. To see what value you really have you should output it to the debugger window usingDebug.WriteLine
, or write it to a file usingFile.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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hampus Karl Sebastian Rude is a new contributor. Be nice, and check out our Code of Conduct.
Hampus Karl Sebastian Rude is a new contributor. Be nice, and check out our Code of Conduct.
Hampus Karl Sebastian Rude is a new contributor. Be nice, and check out our Code of Conduct.
Hampus Karl Sebastian Rude is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
"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 usingDebug.WriteLine
, or write it to a file usingFile.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