2016-03-28 7 views
-5

jsonデータをデコードできません。 私は.NETの機能を次の中からJSONエンコードをしています: - 今デコードJSON.stringifyからデータをデコードするにはどうすればいいですか?

ための機能以下

function(response){ 
    var jsonString = JSON.stringify(response.newhtml); //stringify the JSON created 

    //Send the json data to server 
    //--------------------------- 
    $.ajax({ 
     type: "POST", 
     url: 'url', 
     //dataType:"json", 
     data: { 
      LiRecData: jsonString 
     }, 
    }).done(function(msg){ 
     $('#load_indicator_store').hide(); //Hide loading icon 

     if(msg == 'Success'){ 
      $('#status_save').html('<span class="status_ok">Save.</span>'); 
     } 
     else { 
      $('#status_save').html('<span class="status_error">An error occurred. Please try again after sometime.</span>'); 
     } 
    }); 
} 

ここで私はこの$_POST['LiRecData']

$_POST['LiRecData'] = 
"{"LinkedIn_URL": "https://in.linkedin.com/in/abcsingh","Full_Name": "Abc Singh (Abc - 7K Connections)","Headline": "A Senior Recruitment Professional - Connecting Employers with their prospective assets (Employee)","Company": "Charter Global","Location": "New Delhi Area, India","Industry": "Information Technology and Services","Email": "[email protected]","Phone_Number": "+91-999034656 (Mobile)","Connection_Count": "500+6,336","Photo_URL": "https://media.licdn.com/mpr/mpr/sh1rinknp_400_400/p/3/0105/0b5/352/1ad670e.jpg","Summary": "A Senior Recruitment Professional with over 12+ years of overall experience, majorly in Talent/Client Acquisition, Recruitment, IT Staffing, Business Development, Account Management mainly in Staffing space.<br> 
<br> 
"Connecting Employers with their prospective assets (Employee)"<br> 
<br> 
Helped a Recruitment Startup to achieve his goal and vision.<br> 
<br> 
Connecting Dots and bridging between Talents and Dream Companies...<br> 
<br> 
My personal specialties include:<br> 
<br> 
Permanent/Contract IT Recruitment, Developing new strategies, Research, Client Acquisition, Business Development, Account Management, Client/Industry Mapping, Marketing, Business terms negotiation, Lead development, professional networking and Presentations.<br> 
<br> 
To find out how we can assist you or your business please contact me: <br> 
<br> 
<br> 
Official No: +1-999-999-9933 x 513<br> 
Official Email: [email protected]<br> 
Personal E-mail: [email protected]<br> 
Cell: +91-999999-6656<br> 
<br> 
<br> 
I am a [LION] - feel free to network with me<br> 
<br> 
Specialties: Winning New Business - Candidate Selection - Candidate Handling - Account Management - Recruitment Process - 360 Recruitment Cycle<br> 
<br> 
About Me: <br> 
Abc Singh (Abc Singh), A Senior Recruitment Professional as an Expert in Recruitment, Technical Hiring, Business Development, Account Management, Client Acquisition, Client Delivery, with experience of 12+ years, adept at creative and cost-effective sourcing strategies with a goal of hiring outstanding candidates.","Work_Experience": [{"Title": "Business Development Manager - Staffing/Client Acquisition/Consulting","Company": "Abc","Date_From": "February 2016","Date_To": "Present","Locality": "New Delhi Area, India // Atlanta, GA","More": "Moving further, involved into the Business Development, Client Acquisition, Account Management, majorly in Staffing, Talent Acquisition, Consulting space for the client across Global market. <br> 
"},{"Title": "HeadHunter/Candidate Manager/Researcher/Recruitment Specialist - DACH/UK/Europe.","Company": "Interpro People","Date_From": "August 2013","Date_To": "November 2015","Locality": "London/UK, Noida/India","More": "Recruiting for SAP positions viz; SAP SD, MM, WM/EWM, FI/CO, PP-PI-PM, QM, APO, ABAP/Basis, Business Intelligence experts (SAP BI, SAP BW), SAP BI-IP/Integrated Planning, SAP BusinessObjects and SAP BPC expert candidates and run the EU Enterprise Applications division.<br> 
Involved into the 360 Recruitment, Candidate Management, Researching, Industry/Client Mapping. <br> 
Using Social and professional Networking site to work ahead of job portals.<br> 
Use/Search Innovating method of recruitment and implement within the organization."},{"Title": "Resource Manager","Company": "BeyondTek IT","Date_From": "October 2012","Date_To": "August 2013","Locality": "Placentia, CA 92870","More": "Recruitment, Resourcing, Talent Acquisition, Hiring, Technical Recruitment for IT, Software, Business Process, Product Development, Fortune 500 organizations. <br> 
Involved into overall Recruitment."},{"Title": "Asst. Manager - Recruitment","Company": "Knowledge Momentum","Date_From": "August 2010","Date_To": "August 2012","Locality": "Noida &amp; North Atlanta, GA","More": ""},{"Title": "Asst. Manager - Recruitment","Company": "Izar Associates Inc","Date_From": "June 2008","Date_To": "July 2010","Locality": "","More": "Play a key role in this organization for the recruitment, resourcing and Full Recruitment Life Cycle. Known for its services and timely delivery with optimum quality. Handled the recruitment for Fortune 500 Organizations including some are in the list of Top 50 Fortune Clients."},{"Title": "Team Lead - IT Recruitment","Company": "Ling Technologies","Date_From": "March 2007","Date_To": "April 2008","Locality": "","More": ""},{"Title": "SENIOR IT RECRUITER","Company": "DatamanUSA, LLC","Date_From": "February 2006","Date_To": "February 2007","Locality": "","More": ""},{"Title": "Sr. Officer - Consulting","Company": "Tusthi Executive Access And Consultants","Date_From": "2005","Date_To": "2006","Locality": "","More": ""},{"Title": "SR. Customer Response Executive","Company": "Reliance Infostream Pvt Ltd","Date_From": "November 2003","Date_To": "May 2005","Locality": "","More": ""}],"Education": [{"Institution_Name": "Sikkim Manipal University","Degree": "MBA, HRM","Grade": "","Date_From": "2011","Date_To": "2013"},{"Institution_Name": "Chhatrapati Shahu Ji Maharaj University","Degree": "Bachelor of Arts (B.A.), Economics & English Literature","Grade": "","Date_From": "2000","Date_To": "2003"},{"Institution_Name": "Kendriya Vidyalaya","Degree": "10 & 12th, Economics, Geography, English","Grade": "","Date_From": "1985","Date_To": "1997"}]},"Top_Skills": [{"Endorse_Count": "7","Endorse_Name": "Entrepreneurship"},{"Endorse_Count": "44","Endorse_Name": "Business Development"},{"Endorse_Count": "16","Endorse_Name": "Account Management"},{"Endorse_Count": "8","Endorse_Name": "Client Acquisition"},{"Endorse_Count": "90","Endorse_Name": "Screening"},{"Endorse_Count": "85","Endorse_Name": "IT Recruitment"},{"Endorse_Count": "34","Endorse_Name": "Leadership"},{"Endorse_Count": "99+","Endorse_Name": "Talent Acquisition"},{"Endorse_Count": "61","Endorse_Name": "Management"},{"Endorse_Count": "99+","Endorse_Name": "Technical Recruiting"}]}" 

function decodedata(){ 
    $data = utf8_encode($_POST['LiRecData']); 
    $data = str_replace("'","",$data); 

    $json = json_decode($data, true); 
    print_r($json); 
} 
+0

は、URL 'にリクエストを送っていますか? – roullie

+2

形式の質問は正しく –

+1

あなたの質問のテキストを実際に必要なものに減らしてください。 JSONデータ全体をここに投稿する必要はありません! –

答えて

1

をデコードすることができませんあなたの問題が無効ですJSONテキスト

私はjsonを修正しようとしました。それは醜いことに注意してください。非常に醜い!だから、

、入力としてこれを持つ:

$a = '{"LinkedIn /*trimmed data to fit this format*/ Recruiting"}]}'; 
// you use $a = $_POST['LiRecData']; 

私はいくつかの(いくつかの)既存/正しい要素に基づいてJSONを再構築しようとしたんでした:あなたはここでそれを見ることができます

$a = str_replace(["\n","\t",'<br>','</br>'],'',$a);  // remove new lines, tabs and br tags 
$a = preg_replace ('/([^"])\,([^"])/' , "$1___$2" , $a); // replace commas inside qoutes with SOMETHING 
$a = preg_replace ('/([^"])\:([^"])/' , "$1__|$2" , $a); // replace semicolon inside qoutes with SOMETHING ELSE 
$a = str_replace('"','',$a);        // remove all qoutes 
$a = str_replace(':','":"',$a);       // quote all semicolons 
$a = str_replace(',','","',$a);       // quote all commas 
$a = preg_replace ('/([\{])([a-zA-Z0-9])/' , "$1\"$2" , $a); // {A => {"A 
$a = preg_replace ('/([\:])\"\s([\[])/' , "$1$2" , $a);  // : " [ => : [ 
$a = preg_replace ('/([a-zA-Z0-9])([\}])/' , "$1\"$2" , $a); // adas} => adas"} 
$a = preg_replace ('/([\.])(\s{0,})([\}])/' , "$1\"$3" , $a); 
$a = preg_replace ('/([\"])(\s{1,})([a-zA-Z0-9])/' , "$1$3" , $a); // " Key" => "Key" trim keys 
$a = str_replace(':" }',':"" }',$a); 
$a = str_replace(']","','],"', $a); 
$a = str_replace("___",",",$a);    // revert comment 2 
$a = str_replace("__|",":",$a);    // revert comment 3 
$a = str_replace(']}","Top', '],"Top',$a); //manual fix for TopSkils 

print_r(json_decode($a,true)); 

:「url'`:

https://3v4l.org/QdaiV

+0

アレックスはうまく働いています –

+0

アレックスはうまくやっていますが、その質問は回答が得られる前に修正されているはずだと思っていましたが、そのマッドルを継承する貧しい開発者 –

+0

@simpsojo、確かに。しかし、私が最近見た低品質の質問のうち、少なくともこれには何らかの努力が必要でした。はい、それはまだ「悪い」問題です(多分おそらくローカライズされています)。しかし、:OPはきれいに質問し、問題を特定し(json)、関連するコード/情報を投稿しました。はい、問題ははるかに深いです:jsonsはそのように使用するべきではありません(htmlの転送)。 –

関連する問題