# FILTERJSON

## Content

이 함수는 JSON 문자열에서 데이터를 파싱합니다.

## 구문

`FILTERJSON(json_string)`

## 인수

이 함수는 다음 인수를 가집니다:

| 인수             | 설명                             |
| -------------- | ------------------------------ |
| *json\_string* | \[필수] 유효한 형식의 JSON 문자열 데이터입니다. |

## 참고

JSON 문자열 형식이 올바르지 않으면 #VALUE! 오류가 반환됩니다. 아래는 몇 가지 예와 예상 결과입니다:

| JSON 문자열                     | 수식                                            | 결과                             |
| ---------------------------- | --------------------------------------------- | ------------------------------ |
| {"a": 123}                   | `FILTERJSON("{""a"": 123}")`                  | \[object Object]               |
| "123"                        | `FILTERJSON("123")`                           | 123                            |
| \[1,2, "string"]             | `FILTERJSON([1,2,"string"])`                  | #VALUE!                        |
| {a: 123}                     | `FILTERJSON("{a: 123}")`                      | #VALUE!                        |
| '\[1, "string", {"a": 123}]' | `FILTERJSON("[1, ""string"", {""a"": 123}]")` | 1 \| string \| $object Object$ |

## 데이터 형식

문자열 데이터를 받고 스칼라 값, 객체 또는 객체 배열을 반환합니다.

## 예제

JSON 문자열에서 데이터를 파싱할 수 있습니다.

```JavaScript
var json_string = `{
    "store": {
        "book": [
            {
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            },
            {
                "category": "fiction",
                "author": "Evelyn Waugh",
                "title": "Sword of Honour",
                "price": 12.99
            },
            {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            },
            {
                "category": "fiction",
                "author": "J. R. R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    },
    "expensive": 10
}`;
sheet.setValue(4,0,json_string);
sheet.setFormula(5,0,'=FILTERJSON(A5)');
sheet.setFormula(6,0,'=PROPERTY(A6,"store.book.0.title")'); // "Sayings of the Century"
```

`FILTERJSON` 함수는 [WEBSERVICE](/spreadjs/docs/formulareference/FormulaFunctions/web-functions/webservice) 함수와 함께 사용하여 JSON 데이터를 포함하는 URL을 파싱할 수 있으며, 파싱된 데이터는 [PROPERTY](/spreadjs/docs/formulareference/FormulaFunctions/other-functions/property-function) 함수를 사용하여 표시할 수 있습니다.

```JavaScript
sheet.setFormula(0,0,'=FILTERJSON(WEBSERVICE("https://cors-demo.glitch.me/allow-cors"))'); // WEBSERVICE로 JSON 데이터 가져오기
sheet.setFormula(1,0,'=PROPERTY(A1,"message")'); // "You are handling CORS like a pro!"

spread.options.allowDynamicArray = true; // 동적 배열 허용
sheet.setFormula(2,0,'=FILTERJSON(WEBSERVICE("https://restcountries.eu/rest/v2/name/Japan"))'); // JSON 데이터 가져오기
sheet.setFormula(3,0,'=PROPERTY(A3,"name")'); // "Japan"
```
