Programming :: Get And Process Stuff From JSON Encoded Serialized Data String?
Apr 2, 2010
I have this JSON encoded data, which I want to efficiently parse (i.e. fast, with minimal system resources). I don't want to use a/the shell any more than necessary.
Here's a snippet of what the raw serial data looks like:
Code:
[{"num":1,"name":"1","visible":false,"focused":false,"rect":{"x":0,"y":0,"width":1680,"height":1050},...blah blah..
So that's fine. I currently have at least two ways of parsing it:
This Perl method (which I don't much care for because I'm not much into Perl, and because the output is not much more useful than the raw form, and imho even more cryptic):
Code:
sasha@reactor: <produce data> | perl -MData::Dumper -MJSON::XS -E 'say Dumper(decode_json <>)'
$VAR1 = [
{
code....
# Which means: at x=1680, draw a 20x20px grey block, then back up -10px and draw a "1" on the block.I figure that the two awk's I've used can be combined into one -- but I began having problems with removing the single quotes if I did it within the awk, which is why I stuck a `tr` in the middle.
I know this sucks. So, if someone has some ideas or thoughts on something else to do with this JSON data, that's less convoluted that where I'm currently going, I'll be happy to hear about it.
PS - I know this whole post is possibly hard to understand -- if you need more info (you mean you're interested in this mess?? )
View 13 Replies
ADVERTISEMENT
Jan 10, 2011
I started using Ubuntu's chat tool the other day, I gave it my Gmail username and password,and lo! it found my list of CONTACTS FROM INSIDE GMAIL!Facebook has done the same thing as well! Was this in Google's terms? Can't something be done about this? This is SCARY.But also, a small part of me wants to know how it was done (only a small part, this protocol sh*t is not particularly challenging, right?
View 14 Replies
View Related
Mar 14, 2010
Further to solved LQ thread Bash: how to populate a list of arbitrarily named files?, what is the functional difference between feeding a loop with process substitution and feeding it with a here string with embedded command substitution? ABSG pages: process substitution, here string and command substitution. This works
Code:
while IFS= read -r -d '' file
do
files+=("$file")
done < <(find $dir -type f -print0)
[code]....
View 2 Replies
View Related
Mar 4, 2011
I am trying to generic way to convert the string datatype to other primitive data type. To achieve, i used Template . But i getting error and couldn't resolve the issue and error reported is also clueless.
Code
====
#include <vector>
#include <iostream>
#include <string>
[Code].....
View 7 Replies
View Related
Mar 17, 2011
how to convert a dictionary data-type to a string?
actually I am trying to update some json file 's dictionary.
View 1 Replies
View Related
Apr 10, 2010
I have a very large data file, with 3 numbers in each line, ex. 3 4 5 ; 6 7 8.I want to add two numbers (0 and 1) at the end of every line, and a string at the beginning of the line. Does anyone know a efficient way to do so?
View 7 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Nov 22, 2010
I would like to send struct data from process A to process B but I dont known what is the best way. I have read about IPC, but there are a lot of ways to do it.
View 2 Replies
View Related
Feb 16, 2011
I am trying to automate some directory naming when we're manually running some scripts and are using tee to direct the output to a file (log). Right now this is what we do
Code:
./some_script.sh 2>&1 | tee /home/user/some_dir/logs/manual/some_script_20110216_1628.log
As a matter of laziness and keeping the log files consistently named, I'd like to create a function to pipe it to so that it's doing all the naming How I envision the command running
Code:
./some_script.sh 2>&1 | myfunc
And what the logfile name should look like (and in the right directory)
Code:
some_script_20110216-1628.log
I was thinking of adding a function to our profile to handle this. Just in testing I was trying to stream line right on the command line, but I'm having some difficulty in getting the name of the script that is pushing data over the pipe. Here is what I've tried
Code:
./some_script.sh 2>&1 | tee $(cd ../logs/manual; pwd)/$0_$(date +%Y%m%d)-$(date +%H%M).log
but that created a file named
"bash_20110216-1628.log"
View 3 Replies
View Related
May 3, 2011
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
View 6 Replies
View Related
Oct 16, 2010
I have a set of lines as ahown below:
Leon went to school
Leon came back from school..
Leon had dinner...
I have to replace the line containing "dinner" by a single string LUNCH...
View 2 Replies
View Related
Feb 25, 2011
I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be
1)bcdefg
2)cdefg
3)defg
and so on...
create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?
View 9 Replies
View Related
Apr 18, 2010
So if I'm given a location of a file like:
How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.
View 9 Replies
View Related
Mar 13, 2010
Code:
The error is:
Code:
What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.
My full code is:
Code:
View 1 Replies
View Related
Oct 12, 2009
I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)
[code]....
View 4 Replies
View Related
Nov 11, 2010
I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.
View 4 Replies
View Related
Mar 28, 2009
I am trying to install CentOS 5.2 on an HP rp5700 desktop unit. These units were originally sold as a Point of Sales unit I believe, but HP also markets it as a high life cycle server for SMB market.I tried to load CentOS on this unit via CD (created from downloaded ISO of course). It presents the initial CentOS banner page and waits for the obligatory "enter" to continue. It begins the boot process up to discovering the PCI stuff and just locks up, no response. I have to power down to restart.Since this does not even get to the point of installing. I am at a loss what to do next. Has anyone had a similar issue with other PCs.The boot stops at the lineACPI: PCI Root Bridge [PCI0] (0000:00)
View 3 Replies
View Related
Dec 4, 2010
Trying to use json in a php application. phpInfo says php was configured "--disable-json". Looked around and found json.ini in the /etc/php.d and json.so in /usr/lib/php/modules Trying to run a php application, e.g.php test_client.phpI get the error messages:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: undefined symbol:
ZVAL_DELREF in Unknown on line 0Any why the undefined symbol is there and what to do about it?
View 1 Replies
View Related
Dec 8, 2009
I have two students whose windows laptops are riddled with malware and not working properly. They want me to help them install Linux (which we use in school), but they are concerned about their iTunes.
Having avoided iPods as "defective by design", I know nothing about iTunes whatsoever. However I remember reading about DRM locking and such problems that have me concerned that I won't be able to do it.
Where does iTunes store its stuff?
Can I copy its data store to an external drive, and then into a linux home?
Then will it work on wine, or can another manager (rhythmbox etc) access the itunes data?
Alternatively, if I partition the drive and install linux, can rythmbox/wine/something access itunes data on the win partition?
Supposing they are buying music through iTunes, what will happen to that account?
Finally, one of them has an iphone. Does that work with linux?
Ironic that an apple application is blocking migration away from windows.
View 9 Replies
View Related
Mar 26, 2011
Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?
View 5 Replies
View Related
Jan 11, 2011
I went to [URL] the other day, and I'm really impressed with the way, when you click on domain, it adds it to the cart WITHOUT A REFRESH. But what I really want to know is - how does it do the slick little effect when you click "Add to basket", when it "appears" on the right hand side?
View 4 Replies
View Related
Nov 9, 2010
I have a shell script to identify whether the process is running or not. If the process is not running, then I execute another script file to run my application. Below is my script and saved this script as monitorprocess.sh Code: #!/bin/bash
result=$(ps -ef | grep -v grep | grep "applicationname.sh" | awk '{print $2}')
echo $result
if [ "$result" == "" ];
[code]...
View 4 Replies
View Related
Mar 31, 2011
Is there any difference in cpu usage for process in init.rc(runs automatic when boot is happened) and manually running process. Will these both have same priority by default...?
View 1 Replies
View Related
Nov 26, 2008
I tried googling but didn't get any answer for this.I have a process called "abc" and it is running with PID "123".I have a putty session opened with PID "999".I am giving kill -TERM 123 from putty session.My process "abc" before dying it should catch the PID of the terminal which provided TERM signal to it.Is there any way to find this out
View 2 Replies
View Related
Oct 25, 2010
After upgrading a couple of months ago from Ubuntu server 9.04 to 10.04, transmission stopped working. I have since removed it and reinstalled. It is running as I can start and stop the daemon. However, I can't locate the settings.json file so I can get into it in the browser. The version running is 1.93. I tried searching in multiple directories and even searched using:
Code:
sudo find / -iname settings.json
Nothing came up.
I stopped the daemon and created the file in /etc/transmission-daemon/settings.json with the contents of my old file I had saved elsewhere. Restarted the daemon and I still get the 404 error.
I was suspicious the last step wouldn't work as I was of the opinion that transmission is supposed to generate its own default settings.json file.
View 1 Replies
View Related
Apr 25, 2009
I was wondering if you could recommend a simple way to achieve functionality where received email messages are automatically processed and used in SQL commands (depending on certain criteria, of course). For example, say I have made a PHP-based blog application and it's located at example.com and I'd like to give members the option of posting to their blogs by sending email to a special @example.com address. The email messages received there will be inserted into a database depending on the sender's address, with the body becoming the post and the subject line becoming the post's title, etc.
Another example could be how those trouble ticket systems let customers submit tickets via email, while the support agents operate via a database-driven Web application. Is this the type of thing one must code from scratch, or is there an open source solution out there which only needs to be configured accordingly?
View 4 Replies
View Related
Oct 3, 2010
I'm writing a script that edits a Maya ascii file. Inside the .MA(maya ascii file) there is a line defaultRenderGlobals. My script is supposed to find this line and according to what options they manipulate will update the lines below defaultRenderGlobals. I've got that working... but... the issue i'm having is that defaultRenderGlobals is only made when a the maya scene is made into a batch render. I want my script to manually addefaultRenderGlobals line into the .ma file if its not there and add the certain lines below it.RenderGlobals is already there I want to just manipulate whats below it. Hope this makes sense
View 2 Replies
View Related
May 23, 2011
I'm working on getting transmission-deamon working with remote access.
everything says edit
sudo nano /etc/transmission-daemon/settings.json
specifically "rpc-whitelist
however, as soon as I do. "sudo service transmission-daemon restart" the settings reset.
View 4 Replies
View Related
Mar 31, 2011
I got this part from my script working that it will delete a folder is from 8 days agoEightDaysAgo=`(date --date="8 days ago" +%d-%m-%Y)`rm -rf $EightDaysAgoTarHowever I need to remove files that are older than 8days for example if the script is'nt run for a day it will remove both the 9th and 8th day one not just the 8th day one. If I'm making any sense lol
View 3 Replies
View Related
Jun 11, 2009
I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:
//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;
[code]...
View 1 Replies
View Related