isladogs
MVP / VIP
- Local time
- Today, 10:32
- Joined
- Jan 14, 2017
- Messages
- 18,797
Hi
This ought to be easy but I can't come up with a solution.
First some background
I've been updating the analysis feature used in my JSON parser database https://www.access-programmers.co.uk/forums/showpost.php?p=1545990&postcount=1
I've used code to extract the field names & datatypes and subarrays for a variety of JSON files.
So for example, using this JSON file :
gives me this result
It works well in almost all cases BUT a few JSON files are 'badly' designed:
Now, in this case, I don't want each currency value as a separate field so I've used this code to exclude them:
NOTE: in the above expression, if the 2 items being compared are equal, the result = 0 (confusingly!)
which gives the desired result:
However this one has me foxed:
There should only be 2 fields: Colour & ColourValue but I get all the data:
I can't see anyway of using StrComp as there's nothing I can think of to compare with. One solution I came up with is:
This almost works ...
However, this is likely to exclude 'valid' fields I want to keep in other files
Going round in circles on this ....
Hope all that waffle made sense.
Can anyone point me in the right direction here?
This ought to be easy but I can't come up with a solution.
First some background
I've been updating the analysis feature used in my JSON parser database https://www.access-programmers.co.uk/forums/showpost.php?p=1545990&postcount=1
I've used code to extract the field names & datatypes and subarrays for a variety of JSON files.
So for example, using this JSON file :
Code:
{"id":"0001","type":"donut","name":"Cake","image":{"url":"images/0001.jpg","width": 200,"height": 200},"thumbnail":{"url":"images/thumbnails/0001.jpg","width": 32,"height": 32}}
gives me this result
It works well in almost all cases BUT a few JSON files are 'badly' designed:
Code:
{"base":"GBP","date":"2017-09-19","rates":{"AUD":1.6891,"BGN":2.2069,"BRL":4.2234,"CAD":1.6603,"CHF":1.3016,"CNY":8.8953,"CZK":29.454,"DKK":8.3968,"HKD":10.543,"HRK":8.4341,"HUF":348.5,"IDR":17927.0,"ILS":4.7509,"INR":86.905,"JPY":150.57,"KRW":1525.1,"MXN":23.978,"MYR":5.6645,"NOK":10.541,"NZD":1.8503,"PHP":68.875,"PLN":4.8278,"RON":5.191,"RUB":78.431,"SEK":10.749,"SGD":1.8225,"THB":44.688,"TRY":4.7126,"USD":1.3509,"ZAR":17.992,"EUR":1.1284}}
Now, in this case, I don't want each currency value as a separate field so I've used this code to exclude them:
Code:
If StrComp(UCase(strFieldName), strFieldName, vbBinaryCompare) = 0 Then GoTo NextItem
which gives the desired result:
However this one has me foxed:
Code:
{"aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff","beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2"}
There should only be 2 fields: Colour & ColourValue but I get all the data:
I can't see anyway of using StrComp as there's nothing I can think of to compare with. One solution I came up with is:
Code:
If Left(strValue, 1) = "#" Then GoTo NextItem
This almost works ...
However, this is likely to exclude 'valid' fields I want to keep in other files
Going round in circles on this ....
Hope all that waffle made sense.
Can anyone point me in the right direction here?