Giter Site home page Giter Site logo

Comments (9)

MAGNAT2645 avatar MAGNAT2645 commented on July 17, 2024 1

I have, but if you want to talk about your rewrite there then don't. Sorry.

from sm-json.

clugg avatar clugg commented on July 17, 2024 1

I've just released v4.0.0. You can find the relevant documentation for this feature below:

Thanks again for the suggestion!

from sm-json.

MAGNAT2645 avatar MAGNAT2645 commented on July 17, 2024

You can try to use JSON_Object.Encode with (or without) JSON_ENCODE_PRETTY flag and then File.WriteLine.

JSON_Object hObj = new JSON_Object();
hObj.SetInt( "key1", 50 );
hObj.SetString( "key2", "value" );
hObj.SetBool( "key3", true );

char szBuffer[PLATFORM_MAX_PATH];
BuildPath( Path_SM, szBuffer, sizeof szBuffer, "data/json.txt" );
File hFile = OpenFile( szBuffer, "w" );

hObj.Encode( szBuffer, sizeof szBuffer, JSON_ENCODE_PRETTY );
hFile.WriteLine( "%s", szBuffer );

hFile.Close();
hObj.Close();

from sm-json.

alexevladgabriel avatar alexevladgabriel commented on July 17, 2024

One question, in methodmaps, I had created a function AddField, but that function fails, I had tried to use Length and PushObject but didn't worked, causing handle errors.

property JSON_Array Fields
{
    public get() 
    {
        return view_as<JSON_Array>(this.GetObject("fields"));
    }

    public set(JSON_Array value) 
    {
        this.SetObject("fields", value);
    }
}

public void AddField(const char[] name, const char[] value, bool inline) 
{
    JSON_Object hObj = new JSON_Object();
    hObj.SetString("name", name);
    hObj.SetString("value", value);
    hObj.SetBool("inline", inline);

    JSON_Array hArray = this.Fields;
    PrintToServer("Bool: %i; Fields: %i", hArray.IsArray, this.Fields.IsArray);
    if(hArray == null) {
        hArray = new JSON_Array();
    }

    //json_array_append_new(hArray, hObj);
    hArray.PushObject(hObj);

    this.Fields = hArray;
    delete hArray;
}

Yeah, I realized that and tried. It had worked, but still is somethign what would make a little easy the life of developers.
And I had created a new function json_rename() to be able to rename the key values from JSON.

from sm-json.

MAGNAT2645 avatar MAGNAT2645 commented on July 17, 2024

Are you making something Discord-related? If yes then you should use Discord-API, there are methodmaps for embeds and fields (https://github.com/KillStr3aK/discord-api/blob/main/include/discord/DiscordEmbedField.inc).

from sm-json.

alexevladgabriel avatar alexevladgabriel commented on July 17, 2024

@MAGNAT2645 Yes, I'm rewriting the Discord API code base. The Discord API was using Jansson (extension), and I started yesterday on rewriting all the base to sm-json.

from sm-json.

MAGNAT2645 avatar MAGNAT2645 commented on July 17, 2024

No, Discord-API (which i provided above) uses sm-json.

from sm-json.

alexevladgabriel avatar alexevladgabriel commented on July 17, 2024

Yes, I had saw. I will continue to work on my rewrite with source inspiration from the other vendor.
This is the one, I rewrite Discord-API
Do you have discord? (Scai#8477)

from sm-json.

clugg avatar clugg commented on July 17, 2024

Thanks for the suggestion - will also be focusing on this for the upcoming release.

from sm-json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.