Posts

Showing posts with the label Json

Can't Import JSON In Excel 2016 Using "Get & Transform" Feature

Answer : I ran into the same situation, and then found a work around on the following page: https://techcommunity.microsoft.com/t5/Get-and-Transform-Data/Missing-JSON-option-at-Data-gt-New-query-gt-From-File/td-p/69747 In short, the steps are to: New Query -> From Other Sources -> From Web; Type in (or Copy-Paste) an url to you Json data and hit OK button; After Query Edit opens, right-click a document icon on a query dashboard and select JSON and your data is transformed to a table data format. Thanks to 'Good Boy' who provided the work around in the article mentioned. If the json file is on your computer, a file, you can enter ' file:\c:\filename.json ' in place of the web url. Don't include the '. The easiest way is to use the file browser and copy the path to the file and then add the file name at the end.

Check If A Postgres JSON Array Contains A String

Answer : As of PostgreSQL 9.4, you can use the ? operator: select info->>'name' from rabbits where (info->'food')::jsonb ? 'carrots'; You can even index the ? query on the "food" key if you switch to the jsonb type instead: alter table rabbits alter info type jsonb using info::jsonb; create index on rabbits using gin ((info->'food')); select info->>'name' from rabbits where info->'food' ? 'carrots'; Of course, you probably don't have time for that as a full-time rabbit keeper. Update: Here's a demonstration of the performance improvements on a table of 1,000,000 rabbits where each rabbit likes two foods and 10% of them like carrots: d=# -- Postgres 9.3 solution d=# explain analyze select info->>'name' from rabbits where exists ( d(# select 1 from json_array_elements(info->'food') as food d(# where food::text = '"carrots"' d(# );...

ASN.1 Vs JSON When Is Is Appropriate To Use Them?

Answer : ASN.1 and JSON aren't strictly comparable. JSON is a data format. ASN.1 is a schema language plus multiple sets of encoding rules, each of which produces different data formats for a given schema. So, the original question somewhat parallels the question "XML Schema vs. XML: when is it appropriate to use them?" A fairer comparison would be between ASN.1 and JSON Schema. That said, a few points to consider: ASN.1 has binary encoding rules. Consider whether binary or text encoding is preferable for your application. ASN.1 also has XML and JSON encoding rules. You can opt to go with a text-based encoding using ASN.1, if you like. ASN.1 allows other encoding rules to be developed. Before ITU-T specified encoding rules for JSON, we specified our own rules to encode ASN.1 to JSON. I blogged about this on our company website here As with XML Schema, tools exist for compiling ASN.1. These are commonly referred to as data binding tools. The compiler ...

Angular: 'Cannot Find A Differ Supporting Object '[object Object]' Of Type 'object'. NgFor Only Supports Binding To Iterables Such As Arrays'

Answer : As the error messages stated, ngFor only supports Iterables such as Array , so you cannot use it for Object . change private extractData(res: Response) { let body = <Afdelingen[]>res.json(); return body || {}; // here you are return an object } to private extractData(res: Response) { let body = <Afdelingen[]>res.json().afdelingen; // return array from json file return body || []; // also return empty array if there is no data } Remember to pipe Observables to async, like *ngFor item of items$ | async , where you are trying to *ngFor item of items$ where items$ is obviously an Observable because you notated it with the $ similar to items$: Observable<IValuePair> , and your assignment may be something like this.items$ = this.someDataService.someMethod<IValuePair>() which returns an Observable of type T. Adding to this... I believe I have used notation like *ngFor item of (items$ | async)?.someProperty You only nee...

AWS: Cloud Formation: Is It Possible To Use Multiple "DependsOn"?

Answer : Yes, The DependsOn attribute can take a single string or list of strings . http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html Syntax: "DependsOn" : [ String, ... ] This answer comes up first in Google, so I will include how to do multiple dependson attributes in YAML, which I found in this answer. AnotherProductionResource: Type: AWS::CloudFormation::Stack Condition: ISProduction DependsOn: - AResource - MyProductionResource Properties: [...] Yes, "DependsOn" can take multiple strings. I have listed an example below: "DependsOn": [ "S3BucketAppElbLogs", "ElbLogAppBucketPolicy" ]

Bash CLI Remove Quotes From Output Of A Command

Answer : You can use the tr command to remove the quotes: my_json=$(cat ~/Downloads/json.txt | jq '.name' | tr -d \") In the particular case of jq , you can specify that the output should be in raw format: --raw-output / -r: With this option, if the filter´s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes. This can be useful for making jq fil‐ ters talk to non-JSON-based systems. To illustrate using the sample json.txt file from your link: $ jq '.name' json.txt "Google" whereas $ jq -r '.name' json.txt Google

Chrome Extension Manifest 'Matches'

Answer : You need to surround the value of the content_scripts field in square brackets: "content_scripts": [ { "matches": ["http://*"], "js": ["scripts.js"] } ] (see the Chrome Docs for more info) Incidentally, using http://*/* would be a better match for all urls (see the docs), adding https://*/* if you also need to match those as well. Edit: Following your edit, the error you are getting is because of the match pattern being incorrect. If you want to match every URL, then Google has a special pattern just for this purpose: <all_urls> Sample usage: "matches": ["<all_urls>"], See this page for more info: https://developer.chrome.com/extensions/match_patterns Any match pattern should be of the following structure [scheme] :// [host][path] scheme is '*' | 'http' | 'https' | 'file' | 'ftp' host is ' ' | ' .' (any char...

Array Of JSON Object To Java POJO

Image
Answer : This kind of question is very popular and needs general answer. In case you need generate POJO model based on JSON or JSON Schema use www.jsonschema2pojo.org. Example print screen shows how to use it: How to use it: Select target language. Java in your case. Select source. JSON in your case. Select annotation style. This can be tricky because it depends from library you want to use to serialise/deserialise JSON . In case schema is simple do not use annotations ( None option). Select other optional configuration options like Include getters and setters . You can do that in your IDE as well. Select Preview button. In case schema is big download ZIP with generated classes. For your JSON this tool generates: public class Person { private String ownerName; private List <Pet> pets = null; public String getOwnerName() { return ownerName; } public void setOwnerName(String ownerName) { this.ownerName = ownerName; } public List < Pet ...

Base64 Encode A Javascript Object

Answer : From String to Base-64 var obj = {a: 'a', b: 'b'}; var encoded = btoa(JSON.stringify(obj)) To decode back to actual var actual = JSON.parse(atob(encoded)) For reference look here. https://developer.mozilla.org/en/docs/Web/API/WindowBase64/Base64_encoding_and_decoding You misunderstood the Buffer(str, [encoding]) constructor, the encoding tells the constructor what encoding was used to create str , or what encoding the constructor should use to decode str into a byte array. Basically the Buffer class represents byte streams, it's only when you convert it from/to strings that encoding comes into context. You should instead use buffer.toString("base64") to get base-64 encoded of the buffer content. let objJsonStr = JSON.stringify(obj); let objJsonB64 = Buffer.from(objJsonStr).toString("base64");