jasperdavey / CS490Project

Repository for the CS 490 project
0 stars 0 forks source link

MAJOR ISSUE- IMPROPER FORMAT - HAVE REPORTED THIS IN THE PAST IN ISSUE #21 #41

Closed tramrattan closed 8 years ago

tramrattan commented 8 years ago

NO NULL VALUES should be returned or even a string saying NULL

if a array is supposed to be returned but there is no data, return and empty array

if a string is suppose to be returned and there is no data return an empty string

PLEASE FIX THIS FOR ALL DATA BEING RETURNED

this is what I am getting back [{"id":"3","firstname":"Devin","lastname":"Ramrattan","username":"tr88","email":"tr88@njit.edu","bio":"I am a full stack developer!!!!","image":"http:\/\/web.njit.edu\/~jmd57\/default.jpg","events":"","friends":"","createdEvents":"","pendingFriendRequests":"","tags":""}]} common.js:54 recommended events: {"events":[""]}

as you can see there are empty string in an empty array, so if I check this its saying that there is one item in the array. The array is therefore not empty, but it should be.

as above where there are suppose to be empty arrays there are empty strings, I can not properly parse this.

aml35 commented 8 years ago

{"status":200,"info":{"id":"3","email":"tr88@njit.edu","username":"tr88","firstname":"Devin","lastname":"Ramrattan","bio":"I am a full stack developer!!!!","image":"http:\/\/web.njit.edu\/~jmd57\/default.jpg","events":"","friends":"","tags":[{"id":"10","owner":"3","tag":"#ComputerScience","nice":"0","type":"0"},{"id":"11","owner":"3","tag":"#CS","nice":"0","type":"0"},{"id":"12","owner":"3","tag":"#Software","nice":"0","type":"0"},{"id":"13","owner":"3","tag":"#NJIT","nice":"0","type":"0"}]}}

devin, this is the response from jasper, I cannot change empty strings to empty arrays, if anything should be jasper who change it. I am just echoing the curl's response

tramrattan commented 8 years ago

Assign it to him

On Wednesday, April 20, 2016, Angelica Llerena notifications@github.com wrote:

{"status":200,"info":{"id":"3","email":"tr88@njit.edu javascript:_e(%7B%7D,'cvml','tr88@njit.edu');","username":"tr88","firstname":"Devin","lastname":"Ramrattan","bio":"I am a full stack developer!!!!","image":"http:\/\/web.njit.edu \/~jmd57\/default.jpg","events":"","friends":"","tags":[{"id":"10","owner":"3","tag":"#ComputerScience","nice":"0","type":"0"},{"id":"11","owner":"3","tag":"#CS","nice":"0","type":"0"},{"id":"12","owner":"3","tag":"#Software","nice":"0","type":"0"},{"id":"13","owner":"3","tag":"#NJIT","nice":"0","type":"0"}]}}

devin, this is the response from jasper, I cannot change empty strings to empty arrays, if anything should be jasper who change it. I am just echoing the curl's response

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jasperdavey/CS490Project/issues/41#issuecomment-212393336

aml35 commented 8 years ago

Jasper could you take a look at Devin's request?

jasperdavey commented 8 years ago

So there's a big problem here. MySQL does not handle any sort of arrays. To bypass this, I've used implode() and explode() to convert arrays into a string to save it and convert to array once I need it. By default, there must be some value associated with every key and to represent this default value, NULL is added by MySQL. This means that if you want an empty array returned to you, it must be parsed and every instance of NULL be replaced with "{}" (notice the quotation marks). I believe this can be handled much more easily than having this be parsed. One implementation is to look for NULL as the value of any attribute an ignore it if so. I'm not sure how it is that the JSON is being parsed in either of your systems but in my end, all I could do is give you the values you request, in an appropriate matter that MySQL handles so as not to crash it. If you do decide to go with parsing and replacing, this responsibility belongs to the controller.

TLDR: We should stick to NULL

tramrattan commented 8 years ago

Just save it as a json object as one long string

On Wednesday, April 20, 2016, Jasper Micah Davey notifications@github.com wrote:

So there's a big problem here. MySQL does not handle any sort of arrays. To bypass this, I've used implode() and explode() to convert arrays into a string to save it and convert to array once I need it. By default, there must be some value associated with every key and to represent this default value, NULL is added by MySQL. This means that if you want an empty array returned to you, it must be parsed and every instance of NULL be replaced with "{}" (notice the quotation marks). I believe this can be handled much more easily than having this be parsed. One implementation is to look for NULL as the value of any attribute an ignore it if so. I'm not sure how it is that the JSON is being parsed in either of your systems but in my end, all I could do is give you the values you request, in an appropriate matter that MySQL handles so as not to crash it. If you do decide to go with parsing and replacing, this responsibility belongs to the controller.

TLDR: We should stick to NULL

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jasperdavey/CS490Project/issues/41#issuecomment-212537495

jasperdavey commented 8 years ago

It would be impossible for me to send you "key":{} what will be returned is "key":"{}" or "key":"{""}" if there is an array that was supposed to contain string.

tramrattan commented 8 years ago

PHP can handle json so if possible just format he string your inserting into to the b as a json object with an empty string , then you can always parse the json and work with it then stringify it and insert it back into the db

On Wednesday, April 20, 2016, Jasper Micah Davey notifications@github.com wrote:

It would be impossible for me to send you "key":{} what will be returned is "key":"{}" or "key":"{""}" if there is an array that was supposed to contain string.

— You are receiving this because you were assigned. Reply to this email directly or view it on GitHub https://github.com/jasperdavey/CS490Project/issues/41#issuecomment-212539618