[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with json strings


I have suddenly started getting this error when processing strings from jason

Type mismatch: wanted UseNull, got Boolean instead.

Here is the json string

{

"url": "https://api.github.com/gists/2a452c807c7030eb64a2f1d60d31a830";,

"forks_url": "https://api.github.com/gists/2a452c807c7030eb64a2f1d60d31a830/forks";,

"commits_url": "https://api.github.com/gists/2a452c807c7030eb64a2f1d60d31a830/commits";,

"id": "2a452c807c7030eb64a2f1d60d31a830",

"node_id": "MDQ6R2lzdDJhNDUyYzgwN2M3MDMwZWI2NGEyZjFkNjBkMzFhODMw",

"git_pull_url": "https://gist.github.com/2a452c807c7030eb64a2f1d60d31a830.git";,

"git_push_url": "https://gist.github.com/2a452c807c7030eb64a2f1d60d31a830.git";,

"html_url": "https://gist.github.com/anonymous/2a452c807c7030eb64a2f1d60d31a830";,

"files": {

"playground.gbs": {

"filename": "playground.gbs",

"type": "text/plain",

"language": "Gerber Image",

"raw_url": "https://gist.githubusercontent.com/anonymous/2a452c807c7030eb64a2f1d60d31a830/raw/93e2c3d5c8e21ff6cdea59fd5c253407b1c3dda3/playground.gbs";,

"size": 99,

"truncated": false,

"content": "Public Sub Main()\nDim siList As Short[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n \nPrint siList.Count\n \nEnd",

"encoding": "utf-8"

}

},

"public": true,

"created_at": "2017-08-27T16:40:36Z",

"updated_at": "2017-08-27T16:40:36Z",

"description": "Shared via Gambas Playground",

"comments": 0,

"user": null,

"comments_enabled": true,

"comments_url": "https://api.github.com/gists/2a452c807c7030eb64a2f1d60d31a830/comments";,

"forks": [

],

"history": [

{

"user": {

"login": "invalid-email-address",

"id": 148100,

"node_id": "MDQ6VXNlcjE0ODEwMA==",

"avatar_url": "https://avatars.githubusercontent.com/u/148100?v=4";,

"gravatar_id": "",

"url": "https://api.github.com/users/invalid-email-address";,

"html_url": "https://github.com/invalid-email-address";,

"followers_url": "https://api.github.com/users/invalid-email-address/followers";,

"following_url": "https://api.github.com/users/invalid-email-address/following{/other_user}";,

"gists_url": "https://api.github.com/users/invalid-email-address/gists{/gist_id}";,

"starred_url": "https://api.github.com/users/invalid-email-address/starred{/owner}{/repo}";,

"subscriptions_url": "https://api.github.com/users/invalid-email-address/subscriptions";,

"organizations_url": "https://api.github.com/users/invalid-email-address/orgs";,

"repos_url": "https://api.github.com/users/invalid-email-address/repos";,

"events_url": "https://api.github.com/users/invalid-email-address/events{/privacy}";,

"received_events_url": "https://api.github.com/users/invalid-email-address/received_events";,

"type": "User",

"user_view_type": "public",

"site_admin": false

},

"version": "4e4c304f2ef2446dca0aa139fa56c4ba7dab088d",

"committed_at": "2017-08-27T16:40:36Z",

"change_status": {

"total": 6,

"additions": 6,

"deletions": 0

},

"url": "https://api.github.com/gists/2a452c807c7030eb64a2f1d60d31a830/4e4c304f2ef2446dca0aa139fa56c4ba7dab088d";

}

],

"truncated": false

}

Here is the code that has been working for a few years, do i need to change something?

If DExample.key = "" Then Return ' nothing selected Dim MyUrl As String = "https://api.github.com/gists/"; & Examples[DExample.key] If MyUrl = LastUrl Then Return LastUrl = MyUrl Dim strJson As String Dim jsondb As Variant Try strjson = HttpClient.Download(MyUrl) If Error Or If strjson = "" Then Message(("Error Fetching Code")) Return Endif jsondb = json.Decode(strjson, True) ProgEdit.Clear() For Each v As JsonCollection In jsondb["files"] Try ProgEdit.insert(v["content"]) If Error Then ProgEdit.insert(Error.text & "\n" & Error.where) Endif Next 'Try ProgEdit.insert(jsondb["files"]["playground.gbs"]["content"])

--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: Problems with json stringsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>