Following on from this question, I'd like to open a related one to verify an answer.
Originally my code looked like
string path2key = "C:/Users/me/Downloads/project-id-1-letters.json";
string jsonString = File.ReadAllText(path2key);
Console.WriteLine(jsonString); // this works and prints correctly
// I presume I'm passing json as a string???
var credential = GoogleCredential.FromJson(jsonString);
but I was getting the following error
System.InvalidOperationException: 'Error deserializing JSON credential data.'
FileNotFoundException: Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
I'm using netframework 4.5, meaning I'm somewhat limited in updating packages to the latest and greatest.
The other answer is correct. I was about to post the same answer but #serge beat me to it.
The class GoogleCredentials has a member FromJson. That member takes a string argument. In your code, you were trying to pass an object.
For the error in your comment to the answer:
FileNotFoundException: Could not load file or assembly 'System.Security.Permissions
That error can be corrected by using nuget package manager and adding System.Security.Permissions or via the CLI:
dotnet add package System.Security.Permissions
Related
I'm trying to get this to work
http://fsharp.github.io/FSharp.Data/library/CsvFile.html
But to me it seems like tha CsvFile class and the CSVextionson are removed of the Data lib
I'm running it on Manjaro (Arclinux system)
I'm using the mono compiler (fsharpc)
I got the dotnet core lib
So nothing should be wrong
please help
EDITED
Code
open FSharp.Data
let msft = CsvFile.Load("https://github.com/kam1986/Data-Science-project/blob/master/news_sample.csv")
It is placed in a .fsx file
get hte error message
Fake News.fsx(3,14): error FS0039: The value, namespace, type or module 'CsvFile' is not defined.
I am new to RestAPI testing. I am trying to use Jsonschemavalidor. I added the jar file and all the dependencies. Still I get following error. Can anyone give solution to the problem.
Exception in thread "main" java.lang.NoSuchFieldError: USE_DEFAULTS
at com.fasterxml.jackson.annotation.JsonInclude$Value.<clinit>(JsonInclude.java:205)
at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:543)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:460)
at com.github.fge.jackson.JacksonUtils.newMapper(JacksonUtils.java:155)
at com.github.fge.jackson.JacksonUtils.<clinit>(JacksonUtils.java:55)
at com.github.fge.jackson.JsonNodeReader.<init>(JsonNodeReader.java:82)
at com.github.fge.jackson.JsonLoader.<clinit>(JsonLoader.java:50)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:164)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$JsonSchemaValidatorFactory.create(JsonSchemaValidator.java:254)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath(JsonSchemaValidator.java:117)
at com.nasdaq.api.GenericLib.validateJsonSchema(GenericLib.java:441)
Did you add the latest version of jackson-annotations? The USE_DEFAULTS enum constant was added in 2.6:
I build a simple weka application using Weka 3.7.13 dev version using MAVEN. I have initialise the pom.xml function to get weka library from the repository.
i want to run a simple clustering algorithm using weka, and connecting it to MySQL database. As per documentation, the weka need to have a DatabaseUtil.props file which contains it's jdbc driver. I have setup that.
This is my project structure:
I can retrieve the DatabaseUtils.props using my code below. But somehow the weka itself cannot recognise the jdbc:Url and driver name which i already configure inside.
DatabaseUtil.props file:
# JDBC driver (comma-separated list)
jdbcDriver=com.mysql.jdbc.Driver
# database URL
jdbcURL=jdbc:mysql://127.0.0.1:3306/datamining
Java code which i trigger the Weka module:
public void dm(){
int cluster = 4;
InstanceQuery clusterQuery = null;
try{
//file reader of database utilities properties
ClassLoader classLoader = getClass().getClassLoader();
File fileProps = new File(classLoader.getResource("DatabaseUtils.props").getFile());
//setup the data preparation functionality then connect to database
clusterQuery = new InstanceQuery();
clusterQuery.setUsername("test");
clusterQuery.setPassword("test");
clusterQuery.setQuery("SELECT * FROM TEMP_KMEANS");
clusterQuery.setCustomPropsFile(fileProps);
But when executed the function returning error: java.sql.SQLException: No suitable driver found for jdbc:idb=experiments.prp
It seems that the DatabaseUtils.props file cannot override the default driver value jdbc:idb=experiments.prp
Any ideas why this is throwing?
Any feedback and answer much appreciated.
I created a DatabaseUtils.props file in the src / main / resources folder and wrote the following code. It worked for me, I'm using weka 3.8.0.
File file = new File(getClass().getClassLoader().getResource("DatabaseUtils.props").toURI());
InstanceQuery query = new InstanceQuery();
query.setCustomPropsFile(file);
query.setUsername(MYSQL_USER);
query.setPassword(MYSQL_PASSWORD);
query.setQuery("select * from Action");
instances = query.retrieveInstances();
System.out.println(instances.toString());
The documentation says "These may be changed by creating a java properties file called DatabaseUtils.props in user.home or the current directory". Your properties file does not match those requirements (a properties file in a jar is not on the filesystem). See also Chapter 14 of the Weka manual.
An alternative solution is to set the URL in code using setDatabaseURL. As long as the JDBC driver is on the classpath this should work.
I am building a web application using dart with web_ui.
Everything was working fine until i added the web_ui pub, and now, when I am trying to run a build.dart file I get an error:
Uncaught Error: type 'AttributeName' is not a subtype of type 'String' of 'name'.
What does this mean?
From what I understand, this means there is somewhere an instance named 'name' of class 'AttributeName' that is extending 'String' class.
I searched my entire project and there is nowhere a class named 'AttributeName', nowhere an instance of 'name'.
I have the latest Dart editor and SDK:
Dart Editor version 0.4.7_r21658
Dart SDK version 0.4.7.5_r21658
EDIT:
this is my build.dart file:
import 'package:web_ui/component_build.dart';
import 'dart:io';
void main() {
build(new Options().arguments, ['web/menyplattan.html']);
}
Also, i updated all the pubs
This message looks like web_ui is failing a type check.
The similar SO question MarioP links to has a stacktrace showing this message coming from within the web ui library itself.
Do you have an xmlns attribute in your html?
Have a look at this web-ui issue.
AttributeName is defined within the html5lib library. Perhaps web-ui is expecting a newer version of this library but getting an older one. Make sure you've done a pub install. You can also try deleting your packages folder and doing a fresh pub install.
This could be caused by out-of-date packages, but it could also be a bug in web-ui. See if you can get a stacktrace and file a bug report, or post it on the web-ui mailing list.
Running this code:
var statusResponse = TwitterStatus.Show(tweet.Id);
gives an error message: Unable to parse JSON in the statusResponse object and the ResponseObject comes back as null.
Not sure how to fix this. Any ideas?
I run into the same issue today. It seems that you reference a newer version of Newtonsoft.Json in your project (or maybe an other NuGet package included it).
The problem can be fixed by using the Newtonsoft.Json 4.0.5.0 library that is shipped with the Twitterizer project. It needs to be that exact version.