If you are working with some API or with an IoT device that pushes some data to an API, there is a possibility you might be using JSON for the exchange of request.
We’ll explore everything from converting JSON strings into C# class objects to accessing and modifying your appsettings.json files within your C# projects.
Json isn't a huge language to start with, so libraries for it are likely to be small(er than Xml libraries, at least).There are a whole ton of C libraries linked at Json.org. Maybe one of them will work well for you.
26 Ocak 2021
89 kişi değerlendirdi
6 yorum
{"2_e55c":{"state":{"logo":{"href":"//yandex.com.tr","isForeign":true},"form":{"action":"/search","searchLabel":"Bul","hiddenInputs":[{"name":"lr","value":20815}]},"actions":{"advancedSearch":{"checked":false,"ariaLabel":"Gelişmiş arama"},"moreButtonProps":{"ariaLabel":"Daha fazla"},"cbir":{"name":"cbir","label":"Поиск по картинке","infoUrl":"//yandex.ru/promo/photosearch/index?source=landingdesk","isMacOS":false}},"userSection":{"loggedIn":false,"loginProps":{"loginUrl":"https://passport.yandex.com.tr/auth?retpath=%2F&origin=serp_desktop_auth_new","loginText":"Giriş yap","burgerAriaLabel":"Menü"}},"navigation":{"tabs":[{"id":"www","label":"Arama","url":"//yandex.com.tr","params":{"source":"tabbar"},"target":""},{"id":"images","label":"Görsel","url":"//yandex.com.tr/gorsel/search","params":{"text":"[$query]","noreask":"[$noreask]","nomisspell":"[$nomisspell]","parent-reqid":"[$reqid]","from":"tabbar"}},{"id":"video","label":"Video","url":"//yandex.com.tr/video/search","params":{"text":"[$query]","noreask":"[$noreask]","parent-reqid":"[$reqid]","from":"tabbar"}},{"id":"maps","label":"Haritalar","url":"//yandex.com.tr/harita","params":{"text":"[$query]","source":"serp_navig"}},{"id":"translate","label":"Çeviri","url":"//ceviri.yandex.com.tr","params":{"text":"[$query]","from":"tabbar"}}],"selectedTabId":"www"},"context":{"query":"c json","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","noreask":"1","lr":"20815","counters":{"type":"b","data":{"$header":"0_hsfaz000","logo":"0_hsfaz001","login":"0_hsfaz003","usermenu":"0_hsfaz004","market-cart":"0_hsfaz006","more-button":"0_hsfaz007","cbir":"0_hsfaz008","$navigation":"0_hsfaz009","item":"0_hsfaz00i","tab-www":"0_hsfaz00b","tab-images":"0_hsfaz00d","tab-video":"0_hsfaz00f","tab-maps":"0_hsfaz00h","tab-translate":"0_hsfaz00j"}}},"loggedIn":false,"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"0_hsfaw01-0-1"},"ui":"desktop","service":"web","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","fast":{"name":"header-desktop"}}}}},"type":"header-desktop"},"2_hsfa0":{"state":{"thumbWidth":198,"thumbHeight":113,"videoPreviewHref":"http://www.youtube.com/watch?v=dQyXuFWylm4","internalLinksTarget":"_blank","posterSrc":"//avatars.mds.yandex.net/get-vthumb/3660006/d5f79b41cee65b82f24432f9e12285ef/564x318","videoSrc":"https://video-preview.s3.yandex.net/6cM9ewAAAAA.mp4","videoType":"video/mp4","duration":"7:08","isAdultContent":false,"isVertical":false,"logNode":{"name":"video","attrs":{"externalId":{"entity":"video","id":"3832098859538825538"},"hasVideoViewerLink":false,"hasFilmId":true}},"organicVideoMeta":{"created":"30 Ara 2018","views":"68 bin görüntüleme"},"i18nTexts":{"durationAriaLabel":"Süre","freshAriaLabel":"Yayınlandı"},"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"2_hsfaw09-0-1"},"ui":"desktop","service":"web","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","organic":1}}}},"type":"organic"},"2_hsfa1":{"state":{"answersUrl":"https://stackoverflow.com/questions/6673936/parsing-json-using-c#answers","type":"fact","tabsOptions":[{"id":"question","text":"Soru"},{"id":"bestAnswer","text":"En iyi yanıt"},{"id":"moreAnswers","text":"6 yanıt daha","shortText":"Daha fazla"}],"tabContents":{"question":{"construct":[{"type":"paragraph","content":[{"type":"text","content":"I'm trying to find a good way to parse JSON in C. I really don't need a huge library or anything, I would rather have something small and lightweight with a bare minimum of features, but good documentation. "}]},{"type":"paragraph","content":[{"type":"text","content":"Does anyone have anything they can point me to?"}]}],"footerProps":{"date":1429523227,"numLiked":106,"numCommented":7}},"bestAnswer":{"construct":[{"type":"paragraph","content":[{"type":"text","content":"Json isn't a huge language to start with, so libraries for it are likely to be small(er than Xml libraries, at least)."}]},{"type":"paragraph","content":[{"type":"text","content":"There are a whole ton of "},{"type":"text","content":"C libraries linked at Json.org"},{"type":"text","content":". Maybe one of them will work well for you."}]}],"footerProps":{"date":1611658273,"numLiked":89,"numCommented":6}},"moreAnswers":[{"construct":[{"type":"paragraph","content":[{"type":"text","content":"cJSON"},{"type":"text","content":" has a decent API and is small (2 files, ~700 lines). Many of the other JSON parsers I looked at first were huge... I just want to parse some JSON."}]},{"type":"paragraph","content":[{"type":"text","content":"Edit: We've made "},{"type":"text","content":"some improvements"},{"type":"text","content":" to cJSON over the years."}]}],"footerProps":{"date":1504113954,"numLiked":45,"numCommented":2}},{"construct":[{"type":"paragraph","content":[{"type":"text","content":"NXJSON"},{"type":"text","content":" is full-featured yet very small (~400 lines of code) JSON parser, which has easy to use API:"}]},{"type":"code","content":[{"type":"text","content":[{"type":"text","color":"keyword","content":"const"},{"type":"text","content":" nx_json* json=nx_json_parse_utf8(code);"}]},{"type":"text","content":[{"type":"text","content":"printf("},{"type":"text","color":"string","content":"\"hello=%s\\n\""},{"type":"text","content":", nx_json_get(json, "},{"type":"text","color":"string","content":"\"hello\""},{"type":"text","content":")->text_value);"}]},{"type":"text","content":[{"type":"text","color":"keyword","content":"const"},{"type":"text","content":" nx_json* arr=nx_json_get(json, "},{"type":"text","color":"string","content":"\"my-array\""},{"type":"text","content":");"}]},{"type":"text","content":[{"type":"text","color":"name","content":"int"},{"type":"text","content":" i;"}]},{"type":"text","content":[{"type":"text","color":"keyword","content":"for"},{"type":"text","content":" (i="},{"type":"text","color":"name","content":"0"},{"type":"text","content":"; i\u003carr->length; i++) {"}]},{"type":"text","content":[{"type":"text","content":" "},{"type":"text","color":"keyword","content":"const"},{"type":"text","content":" nx_json* item=nx_json_item(arr, i);"}]},{"type":"text","content":[{"type":"text","content":" printf("},{"type":"text","color":"string","content":"\"arr[%d]=(%d) %ld\\n\""},{"type":"text","content":", i, ("},{"type":"text","color":"name","content":"int"},{"type":"text","content":")item->type, item->int_value);"}]},{"type":"text","content":[{"type":"text","content":"}"}]},{"type":"text","content":[{"type":"text","content":"nx_json_free(json);"}]}]}],"footerProps":{"date":1612659969,"numLiked":13,"numCommented":2}}]},"organic":{"faviconProps":{"src":"https://favicon.yandex.net/favicon/v2/https://stackoverflow.com","size":"m","pageNumber":0,"index":0},"title":"Parsing \u0007[JSON\u0007] using \u0007[C\u0007] [closed]","pathProps":{"items":[{"url":"https://stackoverflow.com/questions/6673936/parsing-json-using-c","text":"stackoverflow.com"},{"url":"https://stackoverflow.com/questions/6673936/parsing-json-using-c","text":"parsing-json-using-c"}]},"faviconPosition":0,"subtitlePosition":1,"linkProps":{"url":"https://stackoverflow.com/questions/6673936/parsing-json-using-c"},"hostTitle":"stackoverflow.com","description":""},"extralinksProps":{"hidden":true,"directions":["bottom-end"],"items":[{"variant":"reportFeedback","reportFeedback":{"feature":"Блок ответов для разработчиков","title":"Bu yanıtta yanlış olan nedir?","checkBoxLabels":[{"value":"Yanıt sorguya uygun değil"},{"value":"Yanıt hatalı"},{"value":"Yanıttaki bilgiler eksik"},{"value":"Diğer"}]}}]},"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"2_hsfaw0c-0-1"},"ui":"desktop","service":"web","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","fast":{"name":"article"}}}}},"type":"article"},"2_hsfa2":{"state":{"linksGroups":[{"type":"geo","links":[{"label":"Columbus","title":"Columbus","url":"//yandex.com.tr/tune/geo","logNode":{"name":"region"},"target":"_self","a11yLabel":"Bölgeniz Columbus","needRetpath":true}]},{"type":"feedback","links":[{"label":"Hata bildir","logNode":{"name":"feedback","attrs":{"behaviour":{"type":"dynamic"}}}}]},{"type":"settings","links":[{"label":"Ayarlar","url":"//yandex.com.tr/tune/search","logNode":{"name":"settings"},"target":"_self","needRetpath":true}]},{"type":"company","links":[{"label":"Hakkımızda","url":"https://company.yandex.com.tr","logNode":{"name":"about"},"target":"_blank"},{"label":"Ticari teklifler","url":"/search/direct?text=c%20json&filters_docs=direct_cm","logNode":{"name":"commercial"},"target":"_blank"},{"label":"Kariyer","url":"//yandex.com.tr/jobs/?utm_source=serp_turkie&utm_medium=footerlink&utm_content=career","logNode":{"name":"vacancy"},"target":"_blank"},{"label":"Kullanım lisansı","url":"//yandex.com.tr/legal/termsofuse/","logNode":{"name":"license"},"target":"_blank"},{"label":"Gizlilik Politikası","url":"//yandex.com.tr/legal/confidential/","logNode":{"name":"confidential"},"target":"_blank"}],"a11yHidden":true}],"reportFeedbackProps":{"feature":"Подвал","title":"Hata bildir","checkBoxLabels":[]},"isSearchApp":false,"hasExtralinks":true,"limitingSelector":".AliceFabButton","baobab":{"parentNode":{"context":{"genInfo":{"prefix":"2_hsfaw0d-0-1"},"ui":"desktop","service":"web","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL"}}}},"type":"serp-footer"},"2_hsfa3":{"state":{"conditionLoadList":{"marketCart":false,"highchartsHighstock":false,"advProductGallery":false,"musicPlayer":false,"ecomRates":false,"photoViewer":false,"easterEggModal":false,"darkmodeChangeDrawer":true},"reportFeedbackBaseProps":{"initEmail":"","metaFields":{"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","userTestids":"186144,124067,1047191,1054383,1052824,1064253,1046719,1064987,1066320,1066380,1010218,1048639,1060223,1054624,1031785,1052306,936724,1066414,1066061,1061176,1055871,1045125,1036351,1068142,1056357,1058366,1065131,1055521,1058161,1065309,1066249,1061537,912327,728509,1061919,1059893,1065202,90498,1064229,151171,126283,13963,287509,220488,338390,1062917,1006026,1053282,1065995,1064726,1054350,1066743,1051466,1052892,912280","yandexuid":"6728018351721301050","uid":"0","queryText":"c json","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","searchSlices":["drawer_search_slice_english","drawer_search_slice_cs"],"userRegionName":"Columbus","userRegionId":"20815"}},"extralinksPopupProps":{"abuseLink":"https://twitter.yandex.com.tr/search/abuse?sign=a52b950ac84dbcea3709f64360c51af2&keyno=0"},"isLoggedIn":false,"userMenuDialogProps":{"flag":"skin,feedback","host":"yandex.com.tr","lang":"tr","project":"serp","queryParams":{"utm_source":"search"},"retpath":"https%3A%2F%2Ftwitter.yandex.com.tr%2Fsearch%3Flr%3D20815%26noreask%3D1%26p%3D0%26rq%3D1%26serp-reload-from%3Drec_bottom%26source%3Dtabbar%26text%3Dc%2Bjson%26ncrnd%3D52662","tld":"com.tr"},"baobab":{"parentNode":{"context":{"genInfo":{"prefix":"2_hsfaw0e-0-1"},"ui":"desktop","service":"web","reqid":"1721301050393866-4699760657072801835-balancer-l7leveler-kubr-yp-vla-203-BAL","fast":{"name":"lazy-load"}}}}},"type":"lazy-load"}}