"Newtonsoft.Json"의 두 판 사이의 차이
(새 문서: == JObject == key, value형태로 key는 string, value는 JToken 타입이다. value는 일반적인 데이터 타입과 JObject, JArray도 가능하다.<syntaxhighlight lang="c#"> JO...) |
|||
(같은 사용자의 중간 판 8개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
== JObject == | == JObject == | ||
− | + | JProperty(name: value)모음으로 클래스처럼 대괄호 블록이다. name은 string, value는 JToken 타입이다. value는 일반적인 데이터 타입과 JObject, JArray도 가능하다.<syntaxhighlight lang="json"> | |
+ | { | ||
+ | JProperty, | ||
+ | JProperty, | ||
+ | name(string): value(JToken) | ||
+ | name: JObject, | ||
+ | name: JArray | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | <syntaxhighlight lang="c#"> | ||
JObject jObject = new JObject(); | JObject jObject = new JObject(); | ||
− | jObject.Add(" | + | jObject.Add("name", "value"); |
</syntaxhighlight><syntaxhighlight lang="c#"> | </syntaxhighlight><syntaxhighlight lang="c#"> | ||
User user = new User { name = "name", age = 1 }; | User user = new User { name = "name", age = 1 }; | ||
JObject jObject = JObject.FromObject(user); | JObject jObject = JObject.FromObject(user); | ||
− | </syntaxhighlight>< | + | </syntaxhighlight> |
+ | == JArray == | ||
+ | JObject와 유사하지만 name없이 value만 가진다. | ||
+ | |||
+ | == Read and Write == | ||
+ | <syntaxhighlight lang="c#"> | ||
+ | JObject.Parse(File.ReadAllText(TYPE_FILE)); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == 외부링크 == | ||
+ | https://www.newtonsoft.com/json | ||
− | + | https://www.newtonsoft.com/json/help/html/Introduction.htm | |
− | + | [[분류:.net]] | |
− | + | [[분류:라이브러리]] |
2022년 5월 22일 (일) 23:17 기준 최신판
JObject[편집 | 원본 편집]
JProperty(name: value)모음으로 클래스처럼 대괄호 블록이다. name은 string, value는 JToken 타입이다. value는 일반적인 데이터 타입과 JObject, JArray도 가능하다.
{
JProperty,
JProperty,
name(string): value(JToken)
name: JObject,
name: JArray
}
JObject jObject = new JObject();
jObject.Add("name", "value");
User user = new User { name = "name", age = 1 };
JObject jObject = JObject.FromObject(user);
JArray[편집 | 원본 편집]
JObject와 유사하지만 name없이 value만 가진다.
Read and Write[편집 | 원본 편집]
JObject.Parse(File.ReadAllText(TYPE_FILE));