I have a csv file with following structure:
Tokens,Tags,Polarities
"['i', 'agree', 'about', 'arafat', '.', 'i', 'mean', ',', 'shit', ',', 'they', 'even', 'gave', 'one', 'to', 'jimmy', 'carter', 'ha', '.', 'it', 'should', 'be', 'called', ""''"", 'the', 'worst', 'president', ""''"", 'prize', '.']","[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]","[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]"
"['musicmonday', 'britney', 'spears', '-', 'lucky', 'do', 'you', 'remember', 'this', 'song', '?', 'it', '`', 's', 'awesome', '.', 'i', 'love', 'it', '.']","[0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]","[-1, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]"
"['wtf', '?', 'hilary', 'swank', 'is', 'coming', 'to', 'my', 'school', 'today', ',', 'just', 'to', 'chill', '.', 'lol', 'wow']","[0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]","[-1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]"
"['my', '3-year-old', 'was', 'amazed', 'yesterday', 'to', 'find', 'that', ""'"", 'real', ""'"", '10', 'pin', 'bowling', 'is', 'nothing', 'like', 'it', 'is', 'on', 'the', 'wii', '...']","[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]","[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1]"
"['God', 'damn', '.', 'That', 'Sony', 'remote', 'for', 'google', 'is', 'fucking', 'hideeeeeous', '!']","[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]","[-1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1]"
I am trying to read the file as follows:
twitter_train = pd.read_csv('twitter_train.csv')
Then I can see that it has a correct structure:
twitter_train.head(3)
Tokens Tags Polarities
0 ['i', 'agree', 'about', 'arafat', '.', 'i', 'm... [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -...
1 ['musicmonday', 'britney', 'spears', '-', 'luc... [0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... [-1, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1,...
2 ['wtf', '?', 'hilary', 'swank', 'is', 'coming'... [0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... [-1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1,...
I want to convert each column to a list of lists, for example:
twitter_train_lists = twitter_train['Tokens'].tolist()
But I have incorrect structure that has an extra \ or " with each element in the list and around each list itself:
['[\'i\', \'agree\', \'about\', \'arafat\', \'.\', \'i\', \'mean\', \',\', \'shit\', \',\', \'they\', \'even\', \'gave\', \'one\', \'to\', \'jimmy\', \'carter\', \'ha\', \'.\', \'it\', \'should\', \'be\', \'called\', "\'\'", \'the\', \'worst\', \'president\', "\'\'", \'prize\', \'.\']',
"['musicmonday', 'britney', 'spears', '-', 'lucky', 'do', 'you', 'remember', 'this', 'song', '?', 'it', '`', 's', 'awesome', '.', 'i', 'love', 'it', '.']",
"['wtf', '?', 'hilary', 'swank', 'is', 'coming', 'to', 'my', 'school', 'today', ',', 'just', 'to', 'chill', '.', 'lol', 'wow']",
'[\'my\', \'3-year-old\', \'was\', \'amazed\', \'yesterday\', \'to\', \'find\', \'that\', "\'", \'real\', "\'", \'10\', \'pin\', \'bowling\', \'is\', \'nothing\', \'like\', \'it\', \'is\', \'on\', \'the\', \'wii\', \'...\']',
"['God', 'damn', '.', 'That', 'Sony', 'remote', 'for', 'google', 'is', 'fucking', 'hideeeeeous', '!']"]
How I can extract lists properly from this csv file to get the correct structure:
[['i', 'agree', 'about', 'arafat', '.', 'i', 'mean', ',', 'shit', ',', 'they', 'even', 'gave', 'one', 'to', 'jimmy', 'carter', 'ha', '.', 'it', 'should', 'be', 'called', "''", 'the', 'worst', 'president', "''", 'prize', '.'],
['musicmonday', 'britney', 'spears', '-', 'lucky', 'do', 'you', 'remember', 'this', 'song', '?', 'it', '`', 's', 'awesome', '.', 'i', 'love', 'it', '.'],
['wtf', '?', 'hilary', 'swank', 'is', 'coming', 'to', 'my', 'school', 'today', ',', 'just', 'to', 'chill', '.', 'lol', 'wow'],
['my', '3-year-old', 'was', 'amazed', 'yesterday', 'to', 'find', 'that', "'", 'real', "'", '10', 'pin', 'bowling', 'is', 'nothing', 'like', 'it', 'is', 'on', 'the', 'wii', '...'],
['God', 'damn', '.', 'That', 'Sony', 'remote', 'for', 'google', 'is', 'fucking', 'hideeeeeous', '!']]
You can find the original dataset file here: https://github.com/1tangerine1day/Aspect-Term-Extraction-and-Analysis/tree/master/data
Update:
I tried another way but have the same problem:
import csv
with open('twitter_train.csv', newline='') as f:
reader = csv.reader(f)
data = list(reader)
Another incorrect output:
print(data[3])
["['wtf', '?', 'hilary', 'swank', 'is', 'coming', 'to', 'my', 'school', 'today', ',', 'just', 'to', 'chill', '.', 'lol', 'wow']", '[0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]', '[-1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]']
Thanks in advance!
Your info in your csv is actually a string not a list. You need to make them actual lists.
twitter_train = pd.read_csv('twitter_train.csv')
twitter_train['Tokens'] = list(twitter_train['Tokens'].str.strip("['").str.rstrip("']").str.split("', '"))
Apache2 crashes and there's no logging in the error.log, not even after setting the Loglevel to debug in the apache2.conf.
Owner of the error.log is root
No updates or changes were made on the Server
Tried to downgrade from Apache (apt-get install --reinstall apache2=2.4.18-2ubuntu3 apache2-bin=2.4.18-2ubuntu3 apache2-data=2.4.18-2ubuntu3) but that doesn't help.
service apache2 start:
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
systemctl status apache2.service:
apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Tue 2017-04-04 16:06:03 UTC; 1min 26s ago
Docs: man:systemd-sysv-generator(8)
Process: 11071 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Apr 04 16:05:43 bpi-iot-ros systemd[1]: Starting LSB: Apache2 web server...
Apr 04 16:05:43 bpi-iot-ros apache2[11071]: * Starting Apache httpd web server apache2
Apr 04 16:06:03 bpi-iot-ros apache2[11071]: *
Apr 04 16:06:03 bpi-iot-ros apache2[11071]: * The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
Apr 04 16:06:03 bpi-iot-ros systemd[1]: apache2.service: Control process exited, code=exited status=1
Apr 04 16:06:03 bpi-iot-ros systemd[1]: Failed to start LSB: Apache2 web server.
Apr 04 16:06:03 bpi-iot-ros systemd[1]: apache2.service: Unit entered failed state.
Apr 04 16:06:03 bpi-iot-ros systemd[1]: apache2.service: Failed with result 'exit-code'.
● service.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
journalctl -xe:
Apr 04 16:09:22 bpi-iot-ros apache2[11191]: *
Apr 04 16:09:22 bpi-iot-ros apache2[11191]: * The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
Apr 04 16:09:22 bpi-iot-ros systemd[1]: apache2.service: Control process exited, code=exited status=1
Apr 04 16:09:22 bpi-iot-ros systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has failed.
--
-- The result is failed.
Apr 04 16:09:22 bpi-iot-ros systemd[1]: apache2.service: Unit entered failed state.
Apr 04 16:09:22 bpi-iot-ros systemd[1]: apache2.service: Failed with result 'exit-code'.
Error log, last lines from Monday:
[Mon Apr 03 08:56:07.530514 2017] [:error] [pid 30594] [client 192.168.2.185:52276] PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:60\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /var/www/nextcloud/lib/private/DB/Connection.php(147): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Obj in /var/www/nextcloud/lib/private/DB/Connection.php on line 60
[Mon Apr 03 08:56:12.034222 2017] [mpm_prefork:notice] [pid 625] AH00169: caught SIGTERM, shutting down
Edit:
apache2ctl configtest no Syntax errors.
apache2ctl -X
Child Process seems to hang up, can reach the SSL Warning (selfsigned) when attempting to reach the sitestarting
did a strace of Apache starting, some Childprocess exited with Errorcode 1 (huge File so i only copied the last Lines)
11028 open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
11028 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331i\1\0004\0\0\0"..., 512) = 512
11028 lseek(3, 894128, SEEK_SET) = 894128
11028 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2960) = 2960
11028 lseek(3, 888324, SEEK_SET) = 888324
11028 read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\3\f"..., 51) = 51
11028 fstat64(3, {st_mode=S_IFREG|0755, st_size=897088, ...}) = 0
11028 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f72000
11028 mmap2(NULL, 963928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e3e000
11028 mprotect(0xb6f14000, 65536, PROT_NONE) = 0
11028 mmap2(0xb6f24000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd6000) = 0xb6f24000
11028 mmap2(0xb6f27000, 9560, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f27000
11028 close(3) = 0
11028 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f71000
11028 set_tls(0xb6f714c0, 0xb6f71b98, 0xb6f7c050, 0xb6f714c0, 0xb6f7c050) = 0
11028 mprotect(0xb6f24000, 8192, PROT_READ) = 0
11028 mprotect(0xb6f51000, 8192, PROT_READ) = 0
11028 mprotect(0x21000, 4096, PROT_READ) = 0
11028 mprotect(0xb6f7b000, 4096, PROT_READ) = 0
11028 munmap(0xb6f73000, 21672) = 0
11028 ioctl(1, TCGETS, 0xbedb2554) = -1 EINVAL (Invalid argument)
11028 brk(NULL) = 0x1d23000
11028 brk(0x1d44000) = 0x1d44000
11028 stat64("/root/.terminfo", 0x1d23160) = -1 ENOENT (No such file or directory)
11028 stat64("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
11028 stat64("/lib/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
11028 stat64("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
11028 gettimeofday({1491321517, 321307}, NULL) = 0
11028 access("/etc/terminfo/x/xterm", R_OK) = -1 ENOENT (No such file or directory)
11028 access("/lib/terminfo/x/xterm", R_OK) = 0
11028 open("/lib/terminfo/x/xterm", O_RDONLY|O_LARGEFILE) = 3
11028 fstat64(3, {st_mode=S_IFREG|0644, st_size=3361, ...}) = 0
11028 read(3, "\32\1)\0&\0\17\0\235\1u\5xterm|xterm-debian|X"..., 4096) = 3361
11028 read(3, "", 4096) = 0
11028 close(3) = 0
11028 gettimeofday({1491321517, 324975}, NULL) = 0
11028 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
11028 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
11028 ioctl(2, TIOCGWINSZ, {ws_row=54, ws_col=189, ws_xpixel=0, ws_ypixel=0}) = 0
11028 fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
11028 write(1, "\33[39;49m", 8) = 8
10941 <... read resumed> "\33[39;49m", 128) = 8
11028 exit_group(0) = ?
10941 read(3, <unfinished ...>
11028 +++ exited with 0 +++
10941 <... read resumed> "", 128) = 0
10941 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11028, si_uid=0, si_status=0, si_utime=0, si_stime=1} ---
10941 sigreturn({mask=[]}) = 0
10941 close(3) = 0
10941 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 11028
10941 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb6fae418) = 11029
11029 close(12 <unfinished ...>
10941 wait4(-1, <unfinished ...>
11029 <... close resumed> ) = 0
11029 close(11) = 0
11029 close(10) = 0
11029 execve("/bin/echo", ["/bin/echo", "-e", " \33[31mfailed!\33[39;49m"], [/* 19 vars */]) = 0
11029 brk(NULL) = 0x318000
11029 uname({sysname="Linux", nodename="bpi-iot-ros", ...}) = 0
11029 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
11029 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f2e000
11029 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
11029 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
11029 fstat64(3, {st_mode=S_IFREG|0644, st_size=21672, ...}) = 0
11029 mmap2(NULL, 21672, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f28000
11029 close(3) = 0
11029 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
11029 open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
11029 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331i\1\0004\0\0\0"..., 512) = 512
11029 lseek(3, 894128, SEEK_SET) = 894128
11029 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2960) = 2960
11029 lseek(3, 888324, SEEK_SET) = 888324
11029 read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\3\f"..., 51) = 51
11029 fstat64(3, {st_mode=S_IFREG|0755, st_size=897088, ...}) = 0
11029 mmap2(NULL, 963928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e1d000
11029 mprotect(0xb6ef3000, 65536, PROT_NONE) = 0
11029 mmap2(0xb6f03000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd6000) = 0xb6f03000
11029 mmap2(0xb6f06000, 9560, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f06000
11029 close(3) = 0
11029 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f27000
11029 set_tls(0xb6f27870, 0xb6f27f48, 0xb6f31050, 0xb6f27870, 0xb6f31050) = 0
11029 mprotect(0xb6f03000, 8192, PROT_READ) = 0
11029 mprotect(0x24000, 4096, PROT_READ) = 0
11029 mprotect(0xb6f30000, 4096, PROT_READ) = 0
11029 munmap(0xb6f28000, 21672) = 0
11029 brk(NULL) = 0x318000
11029 brk(0x339000) = 0x339000
11029 fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
11029 write(1, " \33[31mfailed!\33[39;49m\n", 22) = 22
11029 close(1) = 0
11029 close(2) = 0
11029 exit_group(0) = ?
11029 +++ exited with 0 +++
10941 <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 11029
10941 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11029, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
10941 sigreturn({mask=[]}) = 11029
10941 close(12) = 0
10941 close(11) = 0
10941 exit_group(1) = ?
10941 +++ exited with 1 +++
(Posted on behalf of the OP).
I dont know exactly how, but it's solved... maybe reinstalling libapache2-mod-php7.0 was the failure.
I am working with an API that is sending me a JSON response containing an NSArray of bytes represented with integers.
See link for example (bottom example).
http://developer.yodlee.com/Indy_FinApp/Aggregation_Services_Guide/Aggregation_REST_API_Reference/getMFAResponse
Here is a snippet of that example:
{
"isMessageAvailable":true,
"fieldInfo":{
"responseFieldType":"text",
"imageFieldType":"image",
"image":[
66,
77,
58,
116,
0,
0,
0,
0,
0,
0,
54,
0,
0,
0,
40,
0,
0,
0,
-91,
0,
0,
0,
45,
0,
0,
0,
1,
0,
32,
0,
0,
0,
0,
0,
4,
116,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-5,
-1,
0,
-1,
-1,
-1,
0,
-9,
-9,
-9,
0,
-1,
-5,
-1,
0,
-1,
-1,
-1,
0,
-1,
-5,
-1,
0,
-17,
-17,
-17,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-9,
-13,
-9,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-9,
-9,
-9,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-17,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0,
-1,
-1,
-1,
0
],
"minimumLength":-1,
"maximumLength":-1,
"displayString":"Please enter the text shown in the image"
},
"timeOutTime":99900,
"itemId":10014925,
"retry":false
}
NSJSONSerialization will actually convert this to an NSArray of NSNumbers I believe.
I am confused as to how I would convert an NSArray of NSNumbers to image data.
I looked around on google and found examples in PHP, Java and C++, but nothing specifically for Objective-C/Cocoa.
Does anyone know how to do this?
Something like this should work:
NSArray *jsonBytes = ...
char *bytes = malloc(jsonBytes.count);
NSUInteger index = 0;
for (NSNumber *byteNumber in jsonBytes) {
bytes[index++] = [byteNumber charValue];
}
NSData *data = [NSData dataWithBytesNoCopy:bytes
length:jsonBytes.count
freeWhenDone:YES];
//maybe also specify the scale
UIImage *image = [UIImage imageWithData:data];