<div dir="ltr">maybe i am missing something, but, according to <a href="http://jsonlint.com/">http://jsonlint.com/</a>, <a href="http://www.csociety.org/~kearneyd/tmp/purduepm_json_challenge_1.json">http://www.csociety.org/~kearneyd/tmp/purduepm_json_challenge_1.json</a> is valid json ...</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 28, 2014 at 1:35 PM, derrick <span dir="ltr"><<a href="mailto:derrick@csociety.org" target="_blank">derrick@csociety.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Wow, I think I really messed this one up!<br>
<br>
I was working on the first part of the challenge problem this weekend and had a huge brain fart. I need your help to getting this sample json file cleaned up.<br>
<br>
In our last meeting we learned about the JSON file format. I created the sample json file I wanted to use for the first part of the challenge, but I accidentally mixed up some of values while I was writing the file. To make things worst, my favorite text editor mysteriously now opens json files in read only mode, so I can't just go in and fix it by hand (ugh, technology).<br>

<br>
I uploaded the file here:<br>
<a href="http://www.csociety.org/~kearneyd/tmp/purduepm_json_challenge_1.json" target="_blank">http://www.csociety.org/~<u></u>kearneyd/tmp/purduepm_json_<u></u>challenge_1.json</a><br>
<br>
While I sort things out with my system, if you have a bit of extra time, can you write a program that will do the following:<br>
<br>
1) Read and Parse the JSON file.<br>
<br>
Read the json file into memory and parse it into data structures that best fit the programming language you are using. There are 6 data types you need to worry about:<br>
<br>
Primitive Types:<br>
* null<br>
* booleans<br>
* strings<br>
* numbers<br>
<br>
Structured Types:<br>
* arrays<br>
* objects<br>
<br>
More information about the json file format can be found here:<br>
<a href="http://json.org/" target="_blank">http://json.org/</a><br>
<br>
The file represents a dictionary, or hash table, or associative array.<br>
<br>
There is probably a library available in your programming language, you can use to quickly read and parse the file. The <a href="http://json.org" target="_blank">json.org</a> website has a list of some libraries for popular programming languages.<br>

<br>
After parsing the file into your language's data structures, you should print the values stored in the data structures to stdout or another file to make sure you are reading the data properly. don't just print the file after reading it.<br>

<br>
<br>
2) Fix the JSON file and write it back to disk.<br>
<br>
Here is where it gets tricky. Even though the json file was syntactically correct, I made some mistakes in the data that is stored in it. Here is a summary of what I wanted for each key in the dictionary :<br>
<br>
* null_value should be a json NULL or None value, not a string.<br>
* boolean_true should be a json true value, not false<br>
* boolean_false should be a json false value, not true<br>
* integer_number should be the integer representation of its current value, not the floating point representation (ie 3)<br>
* number_examples -> "not a number" should not even be in the dictionary, lets remove it.<br>
* in "array", the string "value5" should read "value4" to match "key4"<br>
<br>
Can you write a program to make these specific changes? Don't forget to comment your code. If you find an interesting way of addressing elements inside of the structure, please highlight that in your code. For example, how would you find the value for "key4" in the file? If there were multiple dictionary keys named "key4" in the file, how could you make sure you were addressing the correct one?<br>

<br>
The data in the outputted file should look something like like this:<br>
<br>
{<br>
    "null_value": null,<br>
    "boolean_true": true,<br>
    "boolean_false": false,<br>
    "string": "this is my string.",<br>
    "integer_number": 3,<br>
    "number_examples": {<br>
        "positive integer": 9,<br>
        "negative integer": -1,<br>
        "float": 2.3,<br>
        "positive_exponent": 4.35e+58,<br>
        "negative_exponent": 4.3508e-93<br>
    },<br>
    "array": [true,null,["value3"],{"key4":<u></u>"value4"}]<br>
}<br>
<br>
<br>
Note that the order of the keys (null_value, boolean_true, boolean_false, ...) does not matter since the pairs of a json object are unordered.<br>
<br>
<br>
We'll discuss how to perform these actions in the different programming languages people chose to use in the next meeting on May 20, 2014.<br>
<br>
Thanks,<div class="im HOEnZb"><br>
dsk<br>
<br>
<br>
<br>
On 04/15/2014 02:30 PM, Mark Senn wrote:<br>
</div><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Derrick Kearney is going to prepare some JSON and the following people<br>
will talk and/or write about how they read it with the following<br>
programming languages before or at the Purdue Perl Mongers meeting on<br>
May 20, 2014.  Send email to <a href="mailto:markiest@purdue.edu" target="_blank">markiest@purdue.edu</a> (remove "iest" from<br>
the email address) with any corrections or additions to the below list.<br>
<br>
LANGUAGE       WHO<br>
Mathematica    Mark Senn<br>
Perl           Dave Jacoby<br>
PHP            Chris Orr<br>
pro            Mark Senn<br>
Python         Joe Kline<br>
Ruby           Rick Westerman<br>
<br>
Mark Senn, Systems Programmer, Engineering Computer Network, Purdue University<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
Purdue-pm mailing list<br>
<a href="mailto:Purdue-pm@pm.org" target="_blank">Purdue-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/purdue-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/purdue-pm</a><br>
</div></div></blockquote></div><br></div>