convert

Using Google GSON to convert String to JSON Array

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the Google GSON library to convert an ArrayList of countries into JSON: ArrayList<String> countries = new ArrayList<String>(); // arraylist gts populated Gson gson = new Gson(); String json = gson.toJson(countries); Which yields: ["AFGHANISTAN","ALBANIA","ALGERIA","ANDORRA","ANGOLA","ANGUILLA","ANTARCTICA","ANTIGUA AND BARBUDA","ARGENTINA","ARMENIA","ARUBA","ASHMORE AND CARTIER ISLANDS","AUSTRALIA","AUSTRIA","AZERBAIJAN"] How can I modify my code to generate a JSON Array? For example: [ { "AFGHANISTAN", "ALBANIA", "ALGERIA",

codes to convert from avi to asf

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: No matter what library/SDK to use, I want to convert from avi to asf very quickly (I could even sacrifice some quality of video and audio). I am working on Windows platform (Vista and 2008 Server), better .Net SDK/code, C++ code is also fine. :-) I learned from the below link, that there could be a very quick way to convert from avi to asf to support streaming better, as mentioned "could convert the video from AVI to ASF format using a simple copy (i.e. the content is the same, but container changes).". My question is after some hours of

Redshift - Convert epoch string to timestamp

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have got a table with 2 columns epoch_start and epoch_end. I want to find the difference in days of these 2 epochs. The problem i am facing is that the above columns are character varying(5000) type. The query im running is select datediff(day,'1459762341','1450762341') as numdays; The error i get is ERROR: invalid input syntax for type timestamp: "1459762341" 回答1: I have found the solution - To get timestamp from epoch - SELECT (TIMESTAMP 'epoch' + '1459762341' * INTERVAL '1 Second ') as mytimestamp For datediff between two epochs -

IMFTransform interface of Color Converter DSP giving E_INVALIDARG on SetInputType/SetOutputType

匿名 (未验证) 提交于 2019-12-03 09:19:38
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use Color Converter DMO ( http://msdn.microsoft.com/en-us/library/windows/desktop/ff819079(v=vs.85).aspx ) to convert RBG24 to YV12/NV12 via Media Foundation. I've created an instance of Color Converter DSP via CLSID_CColorConvertDMO and then tried to set the needed input/output types, but the calls always return E_INVALIDARG even when using media types that are returned by GetOutputAvailableType and GetInputAvailableType . If I set the media type to NULL then i get the error that the media type is invalid, that makes sense. I

JNI call convert jstring to char*

匿名 (未验证) 提交于 2019-12-03 09:18:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I my cpp code contains a jni function that i wish to convert to const char*. This is the code i am using extern "C" { void Java_com_sek_test_JNITest_printSomething(JNIEnv * env, jclass cl, jstring str) { const char* mystring = env->GetStringUTFChars(env, str, 0); PingoScreen::notify(); } I get an error that no matching function for call to '_JNIEnv::GetStringUTFChars(JNIEnv*&, _jstring*&, int) What am i doing wrong ? 回答1: According to the documentation, GetStringUTFChars const jbyte* GetStringUTFChars(JNIEnv *env, jstring string, jboolean

How do I convert this nested iteration to a recursive solution?

匿名 (未验证) 提交于 2019-12-03 09:18:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this code I wrote that calculates the sum of neighboring elements in a matrix and stores them into another matrix called sum_mat . I need the same result of this code but in a recursive solution and I don't know how to convert nested loops into recursion. void calculate_result(int n,int mat[100][100]) { //calculates an (n-1)x(n-1) matrix in which each element the sum of 4 // neighboring elements in the original matrix. int sum_mat[100][100]; for(int i=1;i<=n-1;i++) { for(int j=1;j<=n-1;j++) sum_mat[i][j]=mat[i][j]+mat[i+1][j]+mat[i][j

QByteArray convert to/from unsigned char *

匿名 (未验证) 提交于 2019-12-03 09:18:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: QByteArray inArray = " ... "; unsigned char *in = convert1(inArray); unsigned char *out; someFunction(in, out); QByteArray outArray = convert2(out); the question is how can I correctly make these conversions (convert1 and convert2). I cannot change someFunction(unsigned char *, unsigned char *), but I have to work with QByteArray here. 回答1: Qt has really great docs , you should use them. If someFunction doesn't modify or store pointer to in data you can use this: QByteArray inArray = " ... "; unsigned char *out; someFunction((unsigned char*)

Is it possible to reliably convert C preprocessor macros to python code?

匿名 (未验证) 提交于 2019-12-03 09:18:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a bunch of C macros the operation of which I need to simulate in python. I saw some pointers to pygccxml or ctypeslib etc. Are these the ways to go? Or is there something out there that is better ? The C macros if and when they change, I would like the python implementation to be auto generated rather than having to make manual modifications. Hence the question. my_c_header.h : #ifdef OS #define NUM_FLAGS (uint16_t)(3) #define NUM_BITS (uint16_t)(8) #else #define NUM_FLAGS (uint16_t)(6) #define NUM_BITS (uint16_t)(16) #endif #define

How to convert an SQL Server BLOB string to System.Drawing.Image?

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: How can I convert a BLOB represented as a string to a System.Drawing.Image type? Background I am going to import information about users together with their photo from a csv file using c#. The proprietary SDK that I use requires the photo to be a System.Drawing.Image Below is an example of the csv file. surname firstname photo Blogs Joe 0xFFD8FFE000104A46494600010101005F005F0000FFDB0043000D090A The photo field is actually 5k chars long and is a direct export of the BLOB field value in the sql server db. We have just taken the raw

Convert escaped string to bytearray or stream; c#

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: My input string consists of a mixture of unicode escape characters with regular characters mixed in. Example: \u 0000 \u 0003 \u 0000 \u 0013timestamp \u 0011clientId \u 0015timeToLive \u 0017destination \u 000fheaders \tbody\u 0013messageId \u 0001 \u 0006 How can I convert this into a bytearray or Stream? EDIT: UTF+8 encoding. To clarify the input string: Char 01 : U + 0000 Char 02 : U + 0003 Char 03 : U + 0000 Char 04 : U + 0013 Char 05 : t Char 06 : i Char 07 : m Char 08 : e Char 09 : s Char 10 : t Char 11 : a Char 12 : m Char