# cJobjectを使ったJSONの扱い方について

**URL:** <https://community.cybozu.dev/t/topic/3159>\
**Category:** kintone 開発相談\
**Created:** [2018 年 6 月 21 日午前 5:44 UTC](https://community.cybozu.dev/t/topic/3159 "2018-06-21T05:44:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account704](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@Legacy\_Account704](https://community.cybozu.dev/u/Legacy_Account704)\
**Post date:** [2018 年 6 月 21 日午前 5:44 UTC](https://community.cybozu.dev/t/topic/3159/1 "2018-06-21T05:44:58Z")

</div>

いつもお世話になっております。  
VBAとkintoneを連携させて、Excel上でデータを表示させるアプリを作成しております。  
JSONLibの提供が停止されているため、第1回および第2回の「 Excelとkintoneを連携させよう」やコミュニティの内容を拝見して  
cJobjectでも実装可能なことが分かったためcjObjectを使って実装しておりますが、JSON形式で格納されているデータから特定のデータ（以下の担当者）の抜出に苦労しております。  
JSON形式のデータおよびVBAのマクロは以下のとおりです。  
まずは最下行でDebug.Printにて担当者を表示させたいのですが、「オブジェクトはこのプロパティまたはメソッドをサポートしていません」と  
エラーとなってしまいます。  
当方もcJobjectに関するページにて調査をおこないましたが原因が分からず、もしお分かりの方がいればアドバイスいただけると幸いです。  
以上よろしくお願いいたします。

===============JSON形式データ（ここから)===============  
{  
&nbsp; “record”: {  
&nbsp; &nbsp; &nbsp; “レコード番号”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “type”: “RECORD\_NUMBER”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“value”: “986”  
&nbsp; &nbsp; &nbsp; },  
&nbsp; &nbsp; &nbsp; “イベント一覧表”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “type”: “SUBTABLE”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “value”: [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “id”: “2974”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “value”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “起案日”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “type”: “DATE”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “value”: “2018-06-19”  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“イベント名”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“type”: “SINGLE\_LINE\_TEXT”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“value”: “一周年感謝祭”  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;},  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“イベント年月日”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “type”: “DATE”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “value”: “2021-06-28”  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “担当者名”: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “type”: “SINGLE\_LINE\_TEXT”,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;“value”: “持田 善行”  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
&nbsp; &nbsp; &nbsp; &nbsp; ]  
&nbsp; &nbsp; }  
&nbsp; }  
}  
===============JSON形式データ（ここまで)===============

===============VBA マクロ（ここから)===============

Dim objHttpReq As MSXML2.XMLHTTP ’ XMLHTTP オブジェクト  
Dim strJSON As String ’ レスポンスで受け取るJSONデータ  
Dim objJSON As cJobject ’ レスポンスの JSON 文字列をパースした情報を格納  
Dim strURL As String ’ アクセス先URL

strURL = “https://\*\*\*.cybozu.com/k/v1/record.json?&app=27&id=986&fields%5B0%5D=$id&fields%5B1%5D=イベント一覧表”

'------------------------------------------------------------------  
’ XMLHTTP オブジェクトを生成する  
'------------------------------------------------------------------  
Set objHttpReq = CreateObject(“MSXML2.XMLHTTP”)  
objHttpReq.Open “GET”, strURL, False

'------------------------------------------------------------------  
’ XMLHTTP のリクエストヘッダーを指定する  
'------------------------------------------------------------------  
’ ログイン認証  
objHttpReq.setRequestHeader “X-Cybozu-Authorization”, “\*\*\*\*\*”  
'ドメイン名：ポート番号  
objHttpReq.setRequestHeader “Host”, “\*\*\*\*\*.cybozu.com” + “:443”  
'キャッシュ対策（常にレスポンスが取得できる状態にする）  
objHttpReq.setRequestHeader “If-Modified-Since”, “Thu, 01 Jun 1970 00:00:00 GMT”

'------------------------------------------------------------------  
’ リクエストを送信する  
'------------------------------------------------------------------  
objHttpReq.send (Null)

'------------------------------------------------------------------  
’ レスポンスを取得する  
'------------------------------------------------------------------  
'レスポンス情報を変数に格納する  
strJSON = objHttpReq.responseText

Set objJSON = JSONParse(strJSON) 'objJSONにデータが入っていることはウォッチウインドウにて確認済

Debug.Print "担当者名: " & objJSON.child(“record”).child(“イベント一覧表”).child(“value”).child(1).child(“value”).child(“担当者名”).child(“value”).value

===============VBA マクロ（ここまで)===============

---

<div class="post-metadata">

**Author:** ![Legacy\_Account704](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@Legacy\_Account704](https://community.cybozu.dev/u/Legacy_Account704)\
**Post date:** [2018 年 6 月 21 日午前 7:05 UTC](https://community.cybozu.dev/t/topic/3159/2 "2018-06-21T07:05:55Z")

</div>

たびたび申し訳ございません。

再実行したところ、無事に動きましたので本質問を取り下げさせていただきます。

お騒がせして申し訳ございませんでした。
