ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Write YAJL docNode to IFS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write YAJL docNode to IFS

    Scott recently added a third parameter to this function so you can save your incoming JSON right to the IFS. It's awesome.

    Code:
    docNode = yajl_stdin_load_tree(*on : errMsg : filename);

    However, now I'm finding I actually want to work with the incoming JSON a bit before saving it. Is there a command to write docNode, which I believe is a pointer (like yajl_val) to the IFS or would I need to convert that to a string and then do an IFS_WRITE?



    Your friends list is empty!

  • #2
    In case it helps anyone else, I went this route. I probably found it in one of Scott's presentations

    Code:
    d retstr                  s                   sqltype(clob:2000000)
    d VARPREF         c                   const(2)      
    d VARPREF4       c                   const(4)      
    d char                   s            1c   ccsid(1200)    ​
    
    
    
    docNode = yajl_stdin_load_tree(*on : errMsg);
    
    x = yajl_stringify( docNode                          
                      : %addr(retstr) + VARPREF4          
                      : %len(retstr) * %size(char)        
                      );                                  
    if (x > 0);                                          
     ​   exec sql 
        CALL QSYS2.IFS_WRITE_UTF8(PATH_NAME => :filename,    
                                  LINE => trim(:retstr),    
                             OVERWRITE => 'APPEND',          
                           END_OF_LINE => 'CRLF');          
    endif;                                                    ​
    Last edited by mjhaston; February 17, 2024, 12:26 PM. Reason: Edited to add the missing "exec sql"
    Your friends list is empty!

    Comment


    • #3
      You certainly didn't gt that "CALL QSYS2.IFSWRITE" business from me. I would never do that...

      Also, wouldn't you need an "EXEC SQL" in there to do that CALL statement? Pretty sure this code won't work as given.

      Comment


      • #4
        I really don't understand this whole thread. You want to receive a JSON document inside a program that's acting as a REST API. Then you apparently want to re-generate a whole new JSON document from it and save that to the IFS rather than saving the original one via yajl_stdin_load_tree. Why do that? Has the data in the JSON changed somehow?

        Why not just read the JSON into your program instead of letting yajl_stdin_load_tree do it for you? Then parse it with yajl_string_load_tree or yajl_buf_load_tree?

        I just don't understand what you're trying to do, here.

        Comment


        • #5
          docNode = yajl_stdin_load_tree(*on : errMsg : filename);

          This works great and is a perfect solution to save the JSON automatically, but later I found that I needed to make sure the sessionid sent with that JSON was valid before writing to the IFS.

          Your friends list is empty!

          Comment


          • #6
            By the way, instead of hardcoding the length of the varying length prefix like this:
            Code:
            %addr(retstr) + VARPREF4
            you can use *DATA with %ADDR like this:
            Code:
            %addr(retstr : *data)
            A massive 82% of Gen Z think NFTs are scams, sprinkled with lies about utilities. And the average person thinks crypto is all about volatile shitcoins. Now, the problem is, how can you market or sell your project to people who already have such notions? Well, the odds are very low. In fact, having utilities here won’t be enough, because oftentimes, they won’t get to see your utilities in the first place. But don’t worry; we recently interviewed the CEO of Fracas, David Evans. For context, Fracas is a full-cycle web3 agency with several successful projects under their belt, from NFT games to NFT arts and crypto solutions.  During the height of the bear market, the agency helped LuckyPunx launch and market a collection of 7,777 NFTs and sell it out. In fact, this collection went on to trend #1 on OpenSea. Mind you, this was in the bear market.  They’re currently helping out Square Enix with end-to-end European marketing to launch its upcoming game, Symbiogensis, as well.  During our conversation with David, here are three important insights he dropped for a successful project:.  1. Define your "Why" and "What." More than 50% of naturally people gravitate towards a brand when they understand the story behind it. So, before thinking about building or launching, you want to get many things right in terms of your vision and mission.  What’s your unique proposition?  Who are you building for?  What are you building, and why are you building it?  When you have a clear idea of this, put it down in writing and blast it everywhere to generate that initial hype before anything else. And most importantly, define the utility of your projects. For example, if you’re launching an NFT project, you could have something like access to exclusive content, voting rights, or community benefits. So, when you’re eventually marketing, this will go a long way in shaping the views of those who already view NFTs as just art JPEGs.  These are the things we usually iron out during any project’s initial consultation with Fracas NFT agency.   2. Build Yourself a Solid Community Most importantly, you need a strong and engaged community around your vision, values, and story. Your community is what will ultimately determine the success of your project, as they are the ones who will support, promote, and buy your NFTs or coins. That’s why we pay utmost attention to community building.  The beauty of community building is that you don’t have to wait until you have your project ready to launch. Start as soon as you have an idea and share your progress, challenges, and feedback with your potential audience. This will help you create anticipation, trust, and loyalty among your fans. Mind you, you don’t need to be on every social media platform, but you need to be where your target audience is. Discord, Twitter, and Instagram are some of the most popular platforms for Web3 enthusiasts, but you can also explore other options like TikTok, Reddit, or Clubhouse. The key is to be consistent, authentic, and engaging on your chosen platforms and provide value to your followers. One of the best ways to grow your community and reach new audiences is to partner with reputable influencers and Collab managers who share your vision and have a large and loyal fan base.  You can collaborate on creating NFTs, co-host events, or cross-promote each other’s projects. Make sure to choose partners who have a good reputation in the web3 space and are not associated with scams or shady practices. 3. Market Your Project Effectively The third and final step for a successful project is effective and creative marketing.  This is necessary to generate awareness, interest, and sales for your project.  Before anything, remember the story you created in #1? Blast them across your marketing channels too. You need to constantly explain what your NFTs represent, why they are valuable, and how they benefit your collectors. You also need to build hype and buzz around your project before, during, and after your launch. You have to think deeply about a campaign that generates excitement, curiosity, and urgency among your potential buyers and collectors. You can use various tactics, such as teasers, trailers, countdowns, giveaways, whitelists, or referrals, to create a sense of anticipation and exclusivity for your project. All these elements might sound like work because you’re probably busy with other aspects of your projects. That’s why I often advise founders to leave them to an NFT marketing agency. 

            Comment

            Working...
            X