browse by category or date

Yesterday, I happened to kaypoh and stared into my friend’s laptop screen. Seeing that he was tinkering with JSON file, I told him about JSON Table Editor and how easy to edit JSON in tabular mode.

So he copy-pasted some part of his JSON string and hit “Load to Grid” button. Voila, it embarrassingly stuck forever at the loading dialog :D.

I apologized for wasting his time, and promised to look into it, once I reached home. Sitting comfy in front of my desktop at home, I start thinking about this bug. I didn’t have the exact JSON string, but I remember that it was a single object with two properties, and both properties are array of string. Below is my first attempt on reconstructing the error-triggering JSON string:

{
    "A0" : ["A0", "B0", "C0"], 
    "A1" : ["A1", "B1", "C1"]
}

But above JSON actually load correctly into the grid:

Not wanting to waste anymore time, I called up my friend and asking for the exact JSON string that he copy-pasted earlier. He sent it to me, but sort of warn me that the string is potentially confidential. Because of that, I can’t share the exact string here. But its structure is more or less like below:

{
    "A0.100.3" : ["A0:A1:A2=TRUE", "B0", "C0"], 
    "A1.200.1" : ["A1:A2:A3=TRUE", "B1", "C1"]
}

At first, I suspected that the string is not a valid JSON. But this was proven to be false. I parse it using JSON.parse and it returns the correct object. So, I continue to debug the code executing it step by step. After a while, I found where that exception was thrown. It was during creation of data Store object:

store = Ext.create('Ext.data.Store', {
    storeId: 'modelStore',
    model: 'mdl'
});
store.add(obj);
grid.reconfigure(store, _cols);

if (grid.filters)
    grid.filters.createFilters();

For now, I just added try-catch to prevent uncaught-exception which causing the loading dialog shown forever.

try {
    store = Ext.create('Ext.data.Store', {
        storeId: 'modelStore',
        model: 'mdl'
    });
    store.add(obj);
    grid.reconfigure(store, _cols);

    if (grid.filters)
        grid.filters.createFilters();
}
catch (eParse) {
    Ext.Msg.hide();
    setTimeout(function(){
        Ext.Msg.alert('Error', eParse);		
    }, 100);
}

The try-catch will catch all exception during data store creation and prompt the error:

Now let’s return to the JSON string and let’s examine it. I did say that the string is a valid JSON. You can validate this by going to your browser’s Web Developer Console, as I shown it below:

As we can see, when calling the object property directly (e.g. o.A0.100.3), we received the same exact exception as when we tried to load this string to grid. Therefore, we can conclude that deep down inside data store creation, the input object property was called directly instead of using array interface (e.g. o[“A0.100.3”]).

I’ll update again once I manage to patch the bug. Till then, cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Another reminder on what is Stay Home Notice (SHN):

[Sent by Gov.sg – 21 Feb]

COVID-19: What should I do if I stay with someone issued with a Stay-Home Notice (SHN)
👥 Avoid close and sustained contact, limit time spent together at common areas
🌬Ensure proper ventilation of room/apartment
🙅‍♀ Avoid having visitors
🍴 Avoid sharing food, crockery, utensils and other personal hygiene items
🧼 Maintain good personal hygiene at all times

SG United 🤝
A one-stop portal to contribute to community efforts, such as volunteering to help those affected by the virus
More: www.sgunited.gov.sg

Update on number of confirmed and discharged cases:

[Sent by Gov.sg]

COVID-19: 21 Feb Update

As of 12pm:
New cases: 1
Total confirmed: 86
Discharged today: 10
Total discharged: 47
Total still in hospital: 39

Most in hospital are stable or improving. 5 are in the intensive care unit.

Today’s new case, a 24 year-old male Singapore Citizen, is linked to a previous case.

More: Go.gov.sg/moh21feb

Stay safe everyone!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Guidelines on workplaces with suspected or confirmed cases:

COVID-19: What should employers do if there are suspected or confirmed cases at the workplace?
MOM’s guidelines say:

For suspect cases, employers should:
👀 Identify close contacts
📝 Notify others of test outcomes
👨‍⚕ Get employees to monitor health, adopt good personal hygiene, see a doctor immediately and stay home if unwell

For confirmed cases, employers should:
🔁 Cooperate with contact tracing officers from MOH
⛔ Vacate and cordon-off the area where the case worked; no need to evacuate floor/building if there’s no sustained and close contact
🧽 Clean and disinfect thoroughly: go.gov.sg/NEAadvisory
💵 Consider providing additional medical coverage

More: go.gov.sg/covid19-workplace

Updates on number of confirmed and recovery cases:

[Sent by Gov.sg]

COVID-19: 20 Feb Update

As of 12pm:
New cases: 1
Total confirmed: 85
Discharged today: 3
Total discharged: 37
Total still in hospital: 48

Most in hospital are stable or improving. 4 remain in ICU.

Today’s new case is a Chinese national, Singapore work pass holder.

Contact tracing is underway to establish any links to previous cases or travel history to China.

More: Go.gov.sg/moh20feb

Thanking our unsung heroes keeping Singapore safe:
Go.gov.sg/togetherwecan

Stay safe and vigilant everyone!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: