Ruby에 익숙하지 않은 모든 사람들이 여기까지 알고 있습니다. 일부 서비스에 대한 쿼리가 있는데 배열이 반환됩니다. 이 코드를 실행하면Ruby 배열 구문 분석
@query_result.each do |test|
puts test
end
나는 정확히 출력을 얻을
["names", ["s", "label"]] ["values", [["<http://www.udfr.org/test-instance#PDF-1>", "\"Acrobat PDF 1.0 - Portable Document Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#BroadcastWave>", "\"Broadcast WAVE\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#PNG-1>", "\"Portable Network Graphics\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#PNG-1-1>", "\"Portable Network Graphics\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#GIF-1989a>", "\"Graphics Interchange Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#TIFF-4>", "\"Tagged Image File Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#TIFF-6>", "\"Tagged Image File Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#BroadcastWave-1>", "\"Broadcast WAVE\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#PNG-1-2>", "\"Portable Network Graphics\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#TIFF-3>", "\"Tagged Image File Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#TIFF-5>", "\"Tagged Image File Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#AVI-Generic>", "\"Audio/Video Interleaved Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#GIF-1987a>", "\"Graphics Interchange Format\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#WaveformAudio>", "\"Waveform Audio\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#BroadcastWave-1>", "\"Broadcast WAVE\"^^<http://www.w3.org/2001/XMLSchema#string>"], ["<http://www.udfr.org/test-instance#BroadcastWave>", "\"Broadcast WAVE\"^^<http://www.w3.org/2001/XMLSchema#string>"]]]
내가이 비밀을 알고 있지만, 기본적으로 난 그냥이의 값을 추출해야합니다
names
s
label
values
배열에서 열의 실제 값을 가져 오는 코드는 무엇이겠습니까?
이 배열의 처음 네 값을 가져 오려고하거나 다른 작업을하려고합니까? – dogenpunk
당신은 @query_result가 무엇인지 언급해야하며 정확히 무엇을 원하니? – shajin
@dogenpunk 아니요, 4 가지 값이 아닙니다. 그것들이 지표입니다. 나는 "레이블"이라고 불리는 열과 "s"라고 불리는 열을 가지고있다 - 나는 그 열의 값을 추출하려고하고있다. – GeekedOut