Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,106 members, 7,849,441 topics. Date: Monday, 03 June 2024 at 09:40 PM

Programming Challenge: Convert String to Json with a Loop - Programming (3) - Nairaland

Nairaland Forum / Science/Technology / Programming / Programming Challenge: Convert String to Json with a Loop (5458 Views)

Professional Html,bootstrap,php,java,json Web Deloper. Pay After Service! / Jamb Past Questions API In JSON / English Dictionary In Xml/json Format (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 10:44am On Apr 27, 2016
Febup:


You are the 3rd winner, well done mate. Enjoy your e-champagne. You even went beyond Lagos and Texas, two bottles for you.

thanks, this is gonna make me e-druk undecided grin
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 10:48am On Apr 27, 2016
crotonite:


thanks, this is gonna make me e-druk undecided grin
So you are an e-drunkard right? i don catch you today.
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 10:57am On Apr 27, 2016
dhtml18:
^^^The programmer above me is a desperado, he is so confident that he can code that he is even thumping his chest and trying to prove that he is the only programmer on this board.
@op, please help him to debug his code (and prove to him that he is just a learner).

undecided
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 11:17am On Apr 27, 2016
crotonite:

undecided
Ehen?
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 11:57am On Apr 27, 2016
dhtml18:
^^^The programmer above me is a desperado, he is so confident that he can code that he is even thumping his chest and trying to prove that he is the only programmer on this board.
@op, please help him to debug his code (and prove to him that he is just a learner).


i won't say my algorithm is bug free, but i can proudly state that i have found none. if you can help me spot one, i have an e-elixir as a reward for you wink.

Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 12:07pm On Apr 27, 2016
donjayzi:
I see, not a problem for me at all, here we go. . . .and i have attached the html source code as well

You are the 5th winner, welcome to the elite Nigerian programmers club.

Re: Programming Challenge: Convert String to Json with a Loop by exxy(m): 1:24pm On Apr 27, 2016
codemarshal08:

Master I sight you !. This is the Id I have been using. Your contribution was useful. Thanks.
all the oga them, i sight u
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 1:32pm On Apr 27, 2016
Febup:


You are the 5th winner, welcome to the elite Nigerian programmers club.
No, i will not gree because you cheated me and I shall explain.

crotonite:

i won't say my algorithm is bug free, but i can proudly state that i have found none. if you can help me spot one, i have an e-elixir as a reward for you wink.
You see, this small boy did one ojoro somewhere in his code:

String json = buffer.toString();
System.out.println(json);
You were supposed to tell him to expand it - like you asked me to expand my first code. This means that I won 2 times. And because my code is shorter. . .especially compared to that of cyrielo who used ecmascript (wey long pass Mississippi + Nile + Niger river and is taller than kilimanjaro+mount everest - am just trying to describe the length and breadth in known dimensions).
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 2:07pm On Apr 27, 2016
donjayzi:


You see, this small boy did one ojoro somewhere in his code:

MAN MAN MAN MAN........


[s]You were supposed to tell him to expand it - like you asked me to expand my first code. This means that I won 2 times. And because my code is shorter. . .especially compared to that of cyrielo who used ecmascript (wey long pass Mississippi + Nile + Niger river and is taller than kilimanjaro+mount everest - am just trying to describe the length and breadth in known dimensions).[/s]
e-medicine after death cool grin grin


the guy below me is about to start NL war
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 2:11pm On Apr 27, 2016
*clears my throat*, i will just pretend i did not see the post above me. But i shall say this, the small boy above me is asking for big big e-trouble wey big pass am.
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 3:19pm On Apr 27, 2016
donjayzi:

No, i will not gree because you cheated me and I shall explain.

Hey bro that will be like asking you to open up this function 'console.log()' though it can be done but that will be for a later challenge.
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 3:22pm On Apr 27, 2016
Errrn, okay, i honourably rest my case. . . .but wait, are you not going to rate the codes like 1st runner up etc ?
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 3:29pm On Apr 27, 2016
donjayzi:
Errrn, okay, i honourably rest my case. . . .but wait, are you not going to rate the codes like 1st runner up etc ?

You guys that have contributed to this challenge are all great programmers including oga dhtml18 and I would prefer to just add new winners as they drop their winning codes.
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 3:56pm On Apr 27, 2016
Oga dhtml18 (my twins brother) has just been running his mouth in a recursive loop. . .wait a minute, where is seunthomas, the phD programmer dude?
Re: Programming Challenge: Convert String to Json with a Loop by ijeezlux(m): 11:26pm On Apr 29, 2016
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
istringstream istring, istring2;
int count=0;
string string_to_process("country\tstate\tcity\r\nnigeria\tlagos\tikeja\r\nunited state\tcalifornia\tlos angeles\r\n"wink;
for(int i=0; i<string_to_process.length(); ++i)
{
if(string_to_process[i]=='\r')
++count;
}

istring.str(string_to_process);
getline(istring, string_to_process, '\r');
istring2.str(string_to_process);
string * identity = new string[3];
for(int i= 0; i<3; ++i)
istring2 >> identity[i];

cout << "[";
while(count >=2)
{
istring.ignore();
cout << "{" << endl;
for(int i= 0; i<3; ++i)
{
if(i==2)
{
getline(istring, string_to_process, '\r');
cout << "\"" << identity[i] << "\"" << "\t" << "\"" << string_to_process << "\"" << endl;
istring.ignore(1);
}

else
{
getline(istring, string_to_process, '\t');
cout << "\"" << identity[i] << "\"" << " " << "\"" << string_to_process << "\"" << endl;
}



}


if(count==2)
cout << "}";
else
cout << "},";
--count;
}
cout << "]" << endl;

delete [] identity;
return 0;
}

Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 11:56am On Apr 30, 2016
^^^You have failed woefully, that output i dey look for here no be json (no need of any jsonlint)!
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 1:06pm On Apr 30, 2016
@dhtml18 Well spotted.

@Ijeezlux Nice try but you missed out the simi-colon between the fields and values and commas after each object except the last object. You can validate you result at this link: http://jsonlint.com
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 1:48pm On Apr 30, 2016
I need someone to tell me how to decrypt a php script using ion cube loader . I don't know how to do that . embarassed

(1) (2) (3) (Reply)

Puzzle of the day / [problem] Write A Program In C++ That Finds The Hcf Of 2 Numbers Without Using A Recursive Function / Thread For Nairaland Algorithm Questions

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.