我希望转换视频在base64字符串,所以我转换migBase64方法通过我的视频在android它将视频转换成字符串成功,但当我解码字符串到视频然后它没有正确转换视频.如果有人知道,请帮助我.
我尝试如下代码:
String encodedString;
//Decode Video To String
File tempFile = new File(Environment.getExternalStorageDirectory()+ "/my/part/my_0.mp4");
byte fileContent[] = new byte[3000];
try {
FileInputStream fin = new FileInputStream(tempFile);
while (fin.read(fileContent) >= 0) {
// b.append(Base64.encodeToString(fileContent, true));
encodedString = Base64.encodeToString(fileContent, true);
}
} catch (IOException e) {
}
//Encoding Video To String Successfully.
//Decode String To Video
try {
byte[] decodedBytes = Base64.decodeF
File file2 = new File(Environment.getExternalStorageDirectory()
+ "/my/Converted.mp4");
FileOutputStream os = new FileOutputStream(file2, true);
os.write(decodedBytes);
os.close();
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud) iOS 中如何将字符串转换为 JSON 对象或 JSON 数组?我的 JSON 字符串就是这样。
{"Data": [{"ID":"1","Name":"Raj"},{"ID":"2","Name":"Rajneesh"}]}
Run Code Online (Sandbox Code Playgroud)
我想从这个字符串中获取 ID 或名称,如果有人现在请帮助我。
谢谢。
我尝试下面的代码但打印 null
NSString *JsonString=@"{"Data": [{"ID":"1","Name":"Raj"},{"ID":"2","Name":"Rajneesh"}]}";
NSData *objectData = [JsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:0 error:&error];
NSArray* array = [json objectForKey:@"Data"];
NSLog(@"Print Array %@",array);
Run Code Online (Sandbox Code Playgroud)