Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,726 members, 7,955,746 topics. Date: Sunday, 22 September 2024 at 02:13 PM |
Nairaland Forum / Science/Technology / Programming / Programming Challenge: Convert String to Json with a Loop (5573 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)
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 10:44am On Apr 27, 2016 |
Febup: thanks, this is gonna make me e-druk |
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 10:48am On Apr 27, 2016 |
crotonite: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: |
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 11:17am On Apr 27, 2016 |
crotonite:Ehen? |
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 11:57am On Apr 27, 2016 |
dhtml18: 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 .
|
Re: Programming Challenge: Convert String to Json with a Loop by Nobody: 12:07pm On Apr 27, 2016 |
donjayzi: 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: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:No, i will not gree because you cheated me and I shall explain. crotonite:You see, this small boy did one ojoro somewhere in his code: String json = buffer.toString();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: 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: 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: 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" 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 . |
If You Are A Developer, Take This Survey And Win $1000(New Survey ) / Retrieving/selecting A Particular Number Of Random Rows From A Database Table / What PHP Framework Do You Consider As The Best
(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. 31 |