Jump to content

Anyone with some insight on parcing THIS text to mysql database?


Recommended Posts

Anyone? Ive parced before but this maybe too complex??

 

{"page_number":1,"total_rows":3,"date":"April, 19 2012 00:44:42","stats":[
{"rnk":1,"top":4,"ref":1000007,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00112,"es":8.0020,"reg":"X","hN":"Defence","s":0,"winP":0.98},
{"rnk":3,"top":2,"ref":1000001,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00112,"es":8.0020,"reg":"X","hN":"Defence","s":0,"winP":0.98},
{"rnk":2,"top":4,"ref":1000000,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00111,"es":7.0002,"reg":"X","hN":"Forward","s":9,"winP":0.12}]}

 

fields.. rnk, top, ref, 3Per, sts, w, p, sF, es, reg, hN, s winP...    all after the : is the data I want.

 

Ive done csv before its simple with , '    but this.. need a little help if possible.

 

exclude {"page_number":1,"total_rows":2,"date":"April, 19 2012 00:44:42","stats":      and start from [  to ]

 

its orignally a text file..  to mysql is the plan.      :shrug:

anyone done json before?? any simple tutorials?? everything ive searched on the net for the past 3 hours is like live from one site to another site..

 

I just need a simple parse and rewrite file to either appear like a csv file (because thats what im familiar with)  or auto input into a mysql database if its possible and less load on the server.

 

thanks. Just a links great! .. or a quick sample code if you have the time.

 

Thx.

Ok another 3 hours later.. json_encode json_decode and json_parse ...  not gettin it. how does it know where the 's are the "'s are the :'s are???  im really old school is everything pluggins today?? like wordpress etc..  I viewed the examples online and thought... how is it possible? ... is todays coding less work?  .... when I was younger we had to build/code it all from scratch.. and BOTHS WAYS!!.  (new age old guy)

 

{"page_number":1,"total_rows":3,"date":"April, 19 2012 00:44:42","stats":

[{"rnk":1,"top":4,"ref":1000007,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00112,"es":8.0020,"reg":"X","hN":"Defence","s":0,"winP":0.98},

{"rnk":3,"top":2,"ref":1000001,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00112,"es":8.0020,"reg":"X","hN":"Defence","s":0,"winP":0.98},

{"rnk":2,"top":4,"ref":1000000,"3Per":1.0,"sts":4,"w":2,"p":2,"sF":00111,"es":7.0002,"reg":"X","hN":"Forward","s":9,"winP":0.12}]}

 

tell me how youd rip the "rnk" numbers and the "top" numbers.. It'll at least give me a jumpstart.. do you guys still do that today?? jumpstart cars?  ;)  oh great lost another commadore key..  thats ok I still got the VIC for backup.

 

 

when I was younger we had to build/code it all from scratch

 

And yet you still can't deal with a simple array structure?

 

im really old school is everything pluggins today??

 

Us youngsters simply choose to use the right tools for the job. No point reinventing the wheel.

 

Now, what have you tried? Post some code and a description of your actual problem.

Thats fine, to anyone else out there who came to this thread for insite,  heres the best possible read online.. trust me ive been to 121 pages in 6 hours.

 

http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.html

 

goodluck!

My machine gave a syntax error on the json you provided. For some reason, it didn't like this part:

"sF":00112

because it starts with zeros. It doesn't like a single zero either, though this link:

 

http://www.json.org/

 

shows that it should be able to start with one zero (which it still errors out if it does). You may want to fix these errors before you keep messing around with json.

hey thorpe  mighty god of wisdom, ya might wanna scroll up and click on the parse_json()  link ya sent me.. thats when I started waiting for someone elses help.  ;)  but thanks pal.

And with thanks like that I can't imagine why no one else wants to help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.