Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a javascript array string looks like this.

"[[["value01","value02","value03",""]],,"value04",,[["value05",[4],1,1,605,0,2,0],["value06",[5],0,0,557,2,4,0]],[["value07",4,[["value08",605,1,1],["value09",0,1,0],["value10",0,1,0],["value11",0,1,0],["value12",0,1,0]],[[0,4],[8,12]],"value13"],["is ?",5,[["value14",557,0,0]],[[5,7],[12,13]],""]],,,[["[[["value01","value02","value03",""]],,"value04",,[["value05",[4],1,1,605,0,2,0],["value06",[5],0,0,557,2,4,0]],[["value07",4,[["value08",605,1,1],["value09",0,1,0],["value10",0,1,0],["value11",0,1,0],["value12",0,1,0]],[[0,4],[8,12]],"value13"],["is ?",5,[["value14",557,0,0]],[[5,7],[12,13]],""]],,,[["en"]],57]15"]],57]"

This is from web request.

What I want to do is to convert that string to C# objects, so that I can access to any values in that string.

The problem is that I do not know how many dimensions it has got.

And the other condition is I cannot use any other 3rd party assembly like JSON.net, so I should solve this out with pure C# code.

Does anyone have any great idea?

share|improve this question
 
Why reinvent the wheel, and what prevents you from using external libraries? –  Frédéric Hamidi Nov 29 at 23:22
 
@FrédéricHamidi It's a customer's stupid demand. –  Joshua Son Nov 29 at 23:36
 
What have you tried already? If you can't use any external library, you'd probably have to write simple state machine your own, and read one character at the time. –  MarcinJuraszek Nov 29 at 23:47
 
Find out why the customer is making this demand; maybe you can convince them to use an external library, maybe there is a reason that would also apply to your own bespoke code. –  Dour High Arch Nov 30 at 2:21
add comment

closed as off-topic by Frédéric Hamidi, Chris Tmas, Strawberry, m59, jprofitt Nov 30 at 2:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist" – Frédéric Hamidi, Chris Tmas, Strawberry, m59, jprofitt
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 1 down vote accepted

You should probably feed this string into a tree, preferably a B-tree.

Again you would have to parse it character by character and traverse in for every [, traverse up for every ] and insert for every ,

Take a look at this for creating a B-tree

share|improve this answer
 
Thanks. I got the idea where to start. –  Joshua Son Nov 30 at 10:04
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.