[plugin] JSON (import/export/generate/edit/inspect/...)

Post your work in progress addons and get feedback

Post » Tue May 31, 2016 4:44 pm

So I create a fix for myself. Now it is able to delete an element of an array.

Say we have JSON like this:
Code: Select all
{"models":[{"id":1,"type":"Type 0"},{"id":2,"type":"Type 1"}]}

Previously, if I set action:
Code: Select all
delete root@"models", 0

The result will be like this: (Note that the first element becomes null.)
Code: Select all
{"models":[null,{"id":2,"type":"Type 1"}]}


So I change the runtime.js at line 405, from this:
Code: Select all
function deleteIfValid(obj,prop) {
   if ( obj !== undefined && obj !== null &&
      (typeof obj === "object") && obj[prop] !== undefined){
               
      delete obj[prop];
   } else {
      log("invalid path: root@"+ path_.toString(),"warn");
   }
}

Into this:
Code: Select all
function deleteIfValid(obj,prop) {

   if ( obj !== undefined && obj !== null && obj[prop] !== undefined ) {

      if( Object.prototype.toString.call( obj ) === '[object Array]' ) {            // If object is an element of an array
         obj.splice(prop,1);                                             // delete element at index prop
      } else if( Object.prototype.toString.call( obj ) === '[object Object]' ) {      // If object is an object
         delete obj[prop];
      }

   } else {
      log("invalid path: root@"+ path_.toString(),"warn");
   }
}
B
33
S
10
G
2
Posts: 46
Reputation: 3,063

Post » Fri Jun 03, 2016 9:51 am

@hlebegue @tmntppn

yeah I knew about this bug, but years ago, I started a new interesting feature and I lost interest in C2.... :D....
so I never released a new version (at that time I was so n00b I wasn't using version control so my fix was mixed with my new feature in progress...)

Anyway, yeah that's basically the fix. I think I'll try to release the fix with that new feature some day.... Work is eating up any will to do anything personal so well... (:
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Sat Jun 04, 2016 1:33 am

@Yann

Great plugins tho. I've been using it in some of my projects and it helps a lot, so thx for the plugins.

Feature suggestion: Find indexof("value"). Is it possible to add a feature to find index in an array? Similar to indexof expression in Array object. What I'm doing now is loop through each element and compare its value one by one. Indexof will make a shorter line of code.
B
33
S
10
G
2
Posts: 46
Reputation: 3,063

Post » Sat Jun 04, 2016 9:39 am

@tmntppn
yeah, the problem is that if I start adding indexOf, I'll have to add push, pop and shift, unshift etc... the plugin will quickly turn into an array plugin.
And also people might want something like that for object (keyOf, etc)...
Well... I'll think about it but since I'm not as motivated as when I started it, because I'm not using c2 anymore, the more feature I'll implement, the higher the risk of bug there will be, and I'd like not to have to spend too much time in maintaining it (:
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Sat Jun 04, 2016 10:04 am

I will continue improve my rex_hash plugin, or @Yann might entrust this Json plugin to someone who can maintain it.
B
108
S
26
G
259
Posts: 4,430
Reputation: 145,679

Post » Sat Jun 04, 2016 11:56 pm

After more than 2 years I finally released a new version :D....

Now everything is hosted on github including the documentation
I'll edit my first post to reflect that.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Mon Jul 04, 2016 3:22 pm

I'm so sorry for my late response @Yann

Many thnks , you are right! The action
Code: Select all
LoadJson
works correctly. I tried use
Code: Select all
SetValue
method because it is more clear for me.

Ahhh I saw that you share this plugin on github, it is fuckying awesome. Thank you so much to share and accept new changes :)
B
3
Posts: 4
Reputation: 183

Post » Wed Jul 06, 2016 3:11 am

We met a issue after updated to V1.2 that chrome log error at "logInvalidPath" if we didn't Commented it
B
72
S
25
G
5
Posts: 89
Reputation: 7,275

Post » Wed Jul 06, 2016 1:30 pm

@totoyan
share a capx with a case that reproduce the bug, so I know if it comes form the plugin, or a misuse of it
if it's a bug from the plugin, I should be able to quickly patch it =)
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Wed Sep 14, 2016 9:18 pm

@Yann is still supporting this plugin? I know @rexrainbow is hesitant about supporting his rex-hash. We might try to migrate to your plugin for all of our JSON stuff pending testing it.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests