2012-03-23 3 views
-2

json으로 포맷 된 배열에서 키 (상태)를 가져 오려고합니다. 내가 필요로 무엇PHP에서 JSON 배열을 구문 분석합니다.

배열

Array ([0] => Running correlate.sh [1] => /var/www/html/blah/Correlation/classes [2] => Executing java command with JSON pps null 93993939 John Smith John Smith 1234 M 01-1-1990 [3] => last name is SMITH [4] => configFilePath is null [5] => feedName is pps [6] => [7] => select distinct(null), guid , scx_eid, emplid, national_ID, last_name, birthdate, first_name from table_a where guid is not null and (scx_eid = '12345678' or emplid = 'null' or (substr(national_ID,length(national_ID)-3,4) = '1234' and upper(last_name) = 'SMITH') or (substr(national_ID, length(national_ID)-3,4) = '1234' and birthdate = '90-null-01-1') or (birthdate = '90-null-01-1' and upper(last_name) = 'SMITH') or (upper(first_name) = 'JOHN' and upper(last_name) = 'ZSCHEILE')) [8] => first match {} [9] => [10] => select distinct(null), guid , eid, last4ssn, lastname, dob, firstname from table_c where guid is not null and (eid = '12345678' or (substr(last4ssn,length(last4ssn)-3,4) = '1234' and upper(lastname) = 'SMITH') or (substr(last4ssn, length(last4ssn)-3,4) = '1234' and dob = '90-null-01-1') or (dob = '90-null-01-1' and upper(lastname) = 'SMITH') or (upper(firstname) = 'JOHN' and upper(lastname) = 'SMITH')) [11] => second match {} [12] => [13] => select distinct(null), guid , eid, emplid from table_d where guid is not null and (eid = '12345678' or emplid = 'null') [14] => third match {} [15] => ldapMatch list is null [16] => returning firstMatch as {} [17] => [18] => Final Status:{Status=DISPUTED, GUID=[]} [19] => {"Status":"DISPUTED","GUID":[]}exiting script) 

$status = 'DISPUTED'; 

업데이트가이 아래에 출력 그래서 내가 자바를 변경 할 수 있었다

. 어떻게하면 $ status와 $ GUID라는 두 개의 변수를 다시 얻을 수 있을까요?

{"Status":"DISPUTED","GUID":[]} 
{"Status":"CONFIRMED","GUID":[G010908712]} 
{"Status":"DISPUTED","GUID":[]} 
{"Status":"DISPUTED","GUID":[]} 
{"Status":"CONFIRMED","GUID":[G403057017]} 
{"Status":"CONFIRMED","GUID":[G104522939]} 
{"Status":"CONFIRMED","GUID":[G020669940]} 
+0

어떤 결과가 나타 납니까? 어떤 결과를 기대합니까? – Brian

+0

아무것도 설정되지 않습니다. $ status = DISPUTED – Jeffrey

답변

1

문자열 exiting script이 JSON 것이다 꼬이지의 말에 정말합니다. 그렇지 않은 경우 json_decode는 객체가 아닌 배열을 지정하기 위해 두 번째 인수를 취합니다.

$json_a = json_decode($array[19], true); 
+0

그렇습니다. 종료 스크립트가 실제로 끝입니다. – Jeffrey

+0

@Jeffrey json_decode가 작동하지 않아서 JSON이 유효하지 않게되므로 JSON이 어디서 왔는지 파악해야합니다. 그것. 원한다면 끝에서 떼어 낼 수도 있지만, 그것은 좀 더 hackish 한 일시적인 해결책입니다. 정말로 문제를 풀고 싶다면 어디에서 왔는지 알아 내야합니다. – Paulpro

+0

json으로 배열의 마지막 줄을 다시 뱉어주기 위해 java를 변경했습니다. 위의 코드를 시도했지만 DISPUTED. – Jeffrey

관련 문제