Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ support JSON. #7

Merged
merged 2 commits into from Sep 9, 2022
Merged

✨ support JSON. #7

merged 2 commits into from Sep 9, 2022

Conversation

crossoverJie
Copy link
Owner

  • Support JSON function.
  • string support ^^.

Complete println class array:

Person[] list = {p1,p2};
// [[1 a] [1 b]]
println(list);
class Person{
	int age;
	string name;
	float weight;
	bool man;
	Person(string n, int a, float w, bool m){
		name = n;
		age = a;
		weight = w;
		man =m;
	}
}
Person p1 = Person("abc",10,99.99,true);
string json = JSON(p1);
println(json);

int age = JSONGet(json, "age");
println(age);
assertEqual(age,10);

string man = JSONGet(json, "man");
println(man);
assertEqual(man,true);

string name = JSONGet(json, "name");
println(name);
assertEqual(name,"abc");

float weight = JSONGet(json, "weight");
println(weight);
assertEqual(weight,99.99);

string j=^{"age":10, "abc":{"def":"def"},"list":[1,2,3]}^;
String def = JSONGet(j, "abc.def");
println(def);
assertEqual(def,"def");
int l1 = JSONGet(j, "list[0]");
println(l1);
assertEqual(l1,1);


string str=^
{
    "name": "bob",
    "age": 20,
    "skill": {
        "lang": [
            {
                "go": {
                    "feature": [
                        "goroutine",
                        "channel",
                        "simple",
                        true
                    ]
                }
            }
        ]
    }
}
^;
String g = JSONGet(str, "skill.lang[0].go.feature[0]");
println(g);
assertEqual(g,"goroutine");

@crossoverJie crossoverJie merged commit 60c9980 into main Sep 9, 2022
@crossoverJie crossoverJie deleted the feature/json branch September 9, 2022 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant