Error:(22, 0) Could not find method android() for arguments [build_8cx....... ] - build.gradle

[Error:(22, 0) Could not find method android() for arguments [build_8cx2vywotwpg6bx8qbm9rw0x0$_run_closure3#292cbb15] on root project 'Photoapp' of type org.gradle.api.Project.]

Related

Postgresql JsonPath: how to identify an array? [duplicate]

I'm struggling with JSONB_PATH_EXISTS Postgres function
I'm using PG 12 and following this documentation : https://www.postgresql.org/docs/12/functions-json.html
With the following request (test it on DBFiddle: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=d5aa984182852438c6f71cf5fa70324e) :
select
json
from (
select '{
"fields": {
"foo": true,
"number": 3,
"listnb": [3, 4],
"listenb2": ["3", "4"],
"txt": "hello how are you",
"listtxt": ["hello","how","are", "you", "3"],
"nullval": null
}
}'::jsonb as json
) t
where 1=1
-- Works with 'strict'
AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', 'strict $ ? (#.type() == "array")')
-- Doesn't work without 'strict'. Why ?
--AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', '$ ? (#.type() == "array")')
-- Can't add a nested condition on an array element value (syntax error)
--AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', 'strict $ ? (#.type() == "array" && #[*] ? (# == "how"))')
;
#1 - I can't get type() function work without strict mode
It could be related to the lax mode unwrapping arrays automatically, but the documentation explicitly states that it is not done when type() function is called :
The lax mode facilitates matching of a JSON document structure and path expression if the JSON data does not conform to the expected schema. [...] Automatic unwrapping is not performed only when:
The path expression contains type() or size() methods that return the type and the number of elements in the array, respectively.
[...]
So I don't understand why we have a difference in the result
#2 I can't get the nested condition work (3rd AND in the sample request)
According to the examples in the documentation, the syntax looks OK but I have a syntax error that I don't understand.
Thank you for your help
If you pass the complete JSON value to the function, then the following works:
where jsonb_path_exists(json, '$ ? (#.fields.listtxt.type() == "array")')
However I would probably simply use jsonb_typeof() without a path query
where jsonb_typeof(json -> 'fields' -> 'listtxt') = 'array'

Postgres : can't make JSONB_PATH_EXISTS work correctly

I'm struggling with JSONB_PATH_EXISTS Postgres function
I'm using PG 12 and following this documentation : https://www.postgresql.org/docs/12/functions-json.html
With the following request (test it on DBFiddle: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=d5aa984182852438c6f71cf5fa70324e) :
select
json
from (
select '{
"fields": {
"foo": true,
"number": 3,
"listnb": [3, 4],
"listenb2": ["3", "4"],
"txt": "hello how are you",
"listtxt": ["hello","how","are", "you", "3"],
"nullval": null
}
}'::jsonb as json
) t
where 1=1
-- Works with 'strict'
AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', 'strict $ ? (#.type() == "array")')
-- Doesn't work without 'strict'. Why ?
--AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', '$ ? (#.type() == "array")')
-- Can't add a nested condition on an array element value (syntax error)
--AND JSONB_PATH_EXISTS(json -> 'fields' -> 'listtxt', 'strict $ ? (#.type() == "array" && #[*] ? (# == "how"))')
;
#1 - I can't get type() function work without strict mode
It could be related to the lax mode unwrapping arrays automatically, but the documentation explicitly states that it is not done when type() function is called :
The lax mode facilitates matching of a JSON document structure and path expression if the JSON data does not conform to the expected schema. [...] Automatic unwrapping is not performed only when:
The path expression contains type() or size() methods that return the type and the number of elements in the array, respectively.
[...]
So I don't understand why we have a difference in the result
#2 I can't get the nested condition work (3rd AND in the sample request)
According to the examples in the documentation, the syntax looks OK but I have a syntax error that I don't understand.
Thank you for your help
If you pass the complete JSON value to the function, then the following works:
where jsonb_path_exists(json, '$ ? (#.fields.listtxt.type() == "array")')
However I would probably simply use jsonb_typeof() without a path query
where jsonb_typeof(json -> 'fields' -> 'listtxt') = 'array'

How to replace string for each item in a list in jsonnet?

How to replace a value in a list in jsonnet. The basic example like this does not seem to work:
local users = import "../data/users.json";
// replace dots in username
local users_new = [
u + { replaced_username: std.strReplace(u.username, ".", "_") }
for u in users
];
{
data: {
[user.replaced_username]: {
username: user.username,
} for user in users_new
}
}
The error message is like this:
RUNTIME ERROR: Field does not exist: strReplace
templates/users.jsonnet:5:32-45 object <anonymous>
templates/users.jsonnet:11:17-38 thunk <b>
std.jsonnet:148:27 thunk <vals>
std.jsonnet:611:21-24
std.jsonnet:611:12-25 thunk <a>
std.jsonnet:611:12-36 function <anonymous>
std.jsonnet:611:12-36 function <anonymous>
std.jsonnet:148:13-28 function <anonymous>
templates/users.jsonnet:11:10-38 object <anonymous>
During manifestation
As I understand from the error message I can't use calculated values in keys or do I miss something here?
UPD: Turned out that std.strReplace function is not present in jsonnet version 0.9.5. Problem solved by copying that function into a template.
In this particular case, because the string to replace has a single character, you could locally implement the function with:
local strReplace(str, a, b) = (
assert std.length(a) == 1;
std.join(b, std.split(str, a))
);
strReplace(strReplace("hello world", "o", "0"), "l", "1")
Above example gives below output:
$ jsonnet -version
Jsonnet commandline interpreter v0.9.5
$ jsonnet strReplace.jsonnet
"he110 w0r1d"

I m trying to use 'ffprobe' with Java or groovy

As per my understanding "ffprobe" will provide file related data in JSON format. So, I have installed the ffprobe in my Ubuntu machine but I don't know how to access the ffprobe JSON response using Java/Grails.
Expected response format:
{
"format": {
"filename": "/Users/karthick/Documents/videos/TestVideos/sample.ts",
"nb_streams": 2,
"nb_programs": 1,
"format_name": "mpegts",
"format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
"start_time": "1.430800",
"duration": "170.097489",
"size": "80425836",
"bit_rate": "3782576",
"probe_score": 100
}
}
This is my groovy code
def process = "ffprobe -v quiet -print_format json -show_format -show_streams HelloWorld.mpeg ".execute()
println "Found ${process.text}"
render process as JSON
I m able to get the process object and i m not able to get the json response
Should i want to convert the process object to json object?
OUTPUT:
Found java.lang.UNIXProcess#75566697
org.codehaus.groovy.grails.web.converters.exceptions.ConverterException: Error converting Bean with class java.lang.UNIXProcess
Grails has nothing to do with this. Groovy can execute arbitrary shell commands in a very simplistic way:
"mkdir foo".execute()
Or for more advanced features, you might look into using ProcessBuilder. At the end of the day, you need to execute ffprobe and then capture the output stream of JSON to use in your app.
Groovy provides a simple way to execute command line processes. Simply
write the command line as a string and call the execute() method.
The execute() method returns a java.lang.Process instance.
println "ffprobe <options>".execute().text
[Source]

Lua-cjson -> require("cjson") successful, then errors when calling cjson.encode

I'm trying to encode/decode JSON in Lua using CJSON. I downloaded lua-cjson using Luarocks (http://www.kyne.com.au/~mark/software/lua-cjson-manual.html).
In the Lua interpreter, I'm using an example from the cjson manual:
> local cjson = require "cjson"
> value = { true, { foo = "bar" } }
> json_text = cjson.encode(value)
stdin:1: attempt to index a nil value (global 'cjson')
stack traceback:
stdin:1: in main chunk
[C]: in ?
I know that cjson is being found, because if I were to do ' require "foobar" ', Lua would error. It's just not able to use the module. Any help would be appreciated.
Each line in an interactive session is a separate chunk. So, the local variable created in line 1 no longer exists in the next lines. Note how the error message mentions a global variable. Try removing local.