杰森的问题 [英] json question

查看:68
本文介绍了杰森的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有 


抱歉这是我第一次来这个网站而没有代码示例但是我想制作一个json编辑器但是差别很小它的格式不同,因为它是文件中的json,但名称是ai_bt




在里面我想在c# 


中打开它并拥有数据网格并阻止代码这是这里的文件结构 

 {
" type":" selector",
" id" :"ZombieDog",
" children" ;: [
{
" type":" parallel",
" id":" ZombieDogBehaviorMain",
" children" ;: [
{
" type":" condition_service_script",
" id":" TargetService",
" scriptFunction":" zombieDogTargetService",
" cooldownMin":0,
" cooldownMax":0
},
{
" type" :" selector",
" id":" ZombieDogBehaviorSelector",
" children" ;: [
{
" type":" sequence",
" id":" DeathBehavior",
" children" ;: [
{
" type":" condition_script",
" id" :"wasKilled",
" interruptName":"death""
},
{
" type":" action",
" id":" defaultAction",
" ActionName":" defaultAction",
" ASMStateName":" death @ zombie_dog",
" TerminateFunction":" startRagdoll",
" loopingAction":0,
" actionTimeMax":0,
" actionNotify":" death"
}
]
},
{
" type":" sequence",
" id":" TraverseBehavior",
"children":[
{
" type":" condition_script",
" id":" shouldTraverse",
" scriptFunction" :" locomotionShouldTraverse",
" interruptName":" traverse"
},
{
" type":" action",
" id":" traverseAction",
" ActionName":" traverseActionStart",
" ASMStateName":" traverse @ zombie_dog",
" loopingAction":0,
" actionTimeMax":0
}
]
},
{
" type":" parallel",
" id":" LocomotionBehavior",
" children":[
{
"type":" condition_script",
" id":" hasPath",
" scriptFunction":" locomotionBehaviorCondition"
},
{
" type":" condition_script_negate",
" id":" shouldMelee",
" scriptFunction":" zombieDogShouldMelee"
},
{
" type":" selector",
" id":" LocomotionTypeSelector",
" children":[
{
" type":" parallel",
" id":" WalkBehavior",
" children":[
{
" type":" condition_script",
" id":" shouldWalk",
" scriptFunction":" zombieDogShouldWalk"
},
{
" type":" action",
" id":" walkAction",
" ActionName":" defaultAction",
" ASMStateName":" walk @ zombie_dog",
" loopingAction":0,
" actionTimeMax":0
}
]
},
{
" type":" parallel",
" id":" RunBehavior",
" children" ;: [
{
" type":" condition_script",
" id":" shouldRun",
" scriptFunction":" zombieDogShouldRun"
},
{
" type":" action",
" id":" runAction",
" ActionName":" defaultAction",
" ASMStateName":" run @ zombie_dog",
" loopingAction":1,
" actionTimeMax":0
}
]
}
]
}
]
},
{
" type":" sequence",
" id":" AIvsAIMeleeBehavior",
" children":[
{
"类型":"" condition_script",
" id":" hasAIvsAIEnemy",
" scriptFunction":" hasAIvsAIEnemy"
},
{
" type":" condition_service_script",
" id":" decisionsInitiator",
" scriptFunction":" decisionInitiator",
" cooldownMin":0,
" cooldownMax":0
},
{
" type":" condition_script",
" id":" isInitiator",
" scriptFunction":" isInitiator"
},
{
" type":" condition_service_script",
" id":" chooseAIvsAIMeleeAnimations",
" scriptFunction":" chooseAIvsAIMeleeAnimations",
" cooldownMin":0,
" cooldownMax":0
},
{
" type":" condition_script",
" id":" hasCloseAIvsAIEnemy",
" scriptFunction":" hasCloseAIvsAIEnemy"
},
{
" type":" action",
" id":" AIvsAIMeleeAction",
" ActionName":" AIvsAIMeleeAction",
" ASMStateName":" void @ debug",
" loopingAction":0,
" actionTimeMax":0
}
]
},
{
" type":" sequence",
" id":" MeleeBehavior",
" children":[
{
&qu ot; type":" condition_script",
" id":" shouldMelee",
" scriptFunction":" zombieDogShouldMelee"
},
{
" type":" action",
" id":" meleeAction",
" ActionName":" zombieDogMeleeAction",
" ASMStateName":" melee @ zombie_dog",
" loopingAction":0,
" actionTimeMax":0,
" actionNotify": " attack_melee"
}
]
},
{
" type":" parallel",
" id":" IdleBehavior",
" children" ;: [
{
" type":" condition_script_negate",
" id":" hasPath",
" scriptFunction" :"locomotionBehaviorCondition":
},
{
" type":" action",
" id":" idleAction",
" ActionName":" defaultAction",
" ASMStateName":" idle @ zombie_dog",
" loopingAction":0,
" actionTimeMax":0
}
]
}
]
}
]
},
{
" type":" action",
" ; id":" DebugVoidAction",
" ActionName":" defaultAction",
" ASMStateName": " void @ debug",
" loopingAction":0,
" actionTimeMax":0
}
]
}

我希望加载它和它的树,当你打开树时,你可以编辑块中的什么并创建自己的键值,但我做了很多研究这个,并不确定最好的方式来实现它或如何实现它这是我第一次想到
这样做,这就是为什么我在这里请求一些帮助我抱歉我没有代码示例。  ;

解决方案

这不是一个小项目。 它有很多部分。 它不仅仅是一个简单的树视图,因为您必须担心对象和列表。 对于单个项目,您需要一种方法来区分字符串,整数,浮点数,
布尔值和空值。 它们都必须区别对待。


我强烈建议你看一下已经存在的一些开源JSON编辑器,看看它们是不是一个好的起点。


https://github.com/jdorn/json-editor


https://github.com/josdejong/jsoneditor


hello all 

sorry this is the first time i ever come on this site with out a code example but i want to make a json editor but the little difference is its in a different format as it is json in the file but the name is ai_bt

and inside i want to open it up in c# 

and have data grid and block code it this is the file structure here 

{
    "type": "selector",
    "id": "ZombieDog",
    "children": [
        {
            "type": "parallel",
            "id": "ZombieDogBehaviorMain",
            "children": [
                {
                    "type": "condition_service_script",
                    "id": "TargetService",
                    "scriptFunction": "zombieDogTargetService",
                    "cooldownMin": 0,
                    "cooldownMax": 0
                },
                {
                    "type": "selector",
                    "id": "ZombieDogBehaviorSelector",
                    "children": [
                        {
                            "type": "sequence",
                            "id": "DeathBehavior",
                            "children": [
                                {
                                    "type": "condition_script",
                                    "id": "wasKilled",
                                    "interruptName": "death"
                                },
                                {
                                    "type": "action",
                                    "id": "defaultAction",
                                    "ActionName": "defaultAction",
                                    "ASMStateName": "death@zombie_dog",
                                    "TerminateFunction": "startRagdoll",
                                    "loopingAction": 0,
                                    "actionTimeMax": 0,
                                    "actionNotify": "death"
                                }
                            ]
                        },
                        {
                            "type": "sequence",
                            "id": "TraverseBehavior",
                            "children": [
                                {
                                    "type": "condition_script",
                                    "id": "shouldTraverse",
                                    "scriptFunction": "locomotionShouldTraverse",
                                    "interruptName": "traverse"
                                },
                                {
                                    "type": "action",
                                    "id": "traverseAction",
                                    "ActionName": "traverseActionStart",
                                    "ASMStateName": "traverse@zombie_dog",
                                    "loopingAction": 0,
                                    "actionTimeMax": 0
                                }
                            ]
                        },
                        {
                            "type": "parallel",
                            "id": "LocomotionBehavior",
                            "children": [
                                {
                                    "type": "condition_script",
                                    "id": "hasPath",
                                    "scriptFunction": "locomotionBehaviorCondition"
                                },
                                {
                                    "type": "condition_script_negate",
                                    "id": "shouldMelee",
                                    "scriptFunction": "zombieDogShouldMelee"
                                },
                                {
                                    "type": "selector",
                                    "id": "LocomotionTypeSelector",
                                    "children": [
                                        {
                                            "type": "parallel",
                                            "id": "WalkBehavior",
                                            "children": [
                                                {
                                                    "type": "condition_script",
                                                    "id": "shouldWalk",
                                                    "scriptFunction": "zombieDogShouldWalk"
                                                },
                                                {
                                                    "type": "action",
                                                    "id": "walkAction",
                                                    "ActionName": "defaultAction",
                                                    "ASMStateName": "walk@zombie_dog",
                                                    "loopingAction": 0,
                                                    "actionTimeMax": 0
                                                }
                                            ]
                                        },
                                        {
                                            "type": "parallel",
                                            "id": "RunBehavior",
                                            "children": [
                                                {
                                                    "type": "condition_script",
                                                    "id": "shouldRun",
                                                    "scriptFunction": "zombieDogShouldRun"
                                                },
                                                {
                                                    "type": "action",
                                                    "id": "runAction",
                                                    "ActionName": "defaultAction",
                                                    "ASMStateName": "run@zombie_dog",
                                                    "loopingAction": 1,
                                                    "actionTimeMax": 0
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "type": "sequence",
                            "id": "AIvsAIMeleeBehavior",
                            "children": [
                                {
                                    "type": "condition_script",
                                    "id": "hasAIvsAIEnemy",
                                    "scriptFunction": "hasAIvsAIEnemy"
                                },
                                {
                                    "type": "condition_service_script",
                                    "id": "decideInitiator",
                                    "scriptFunction": "decideInitiator",
                                    "cooldownMin": 0,
                                    "cooldownMax": 0
                                },
                                {
                                    "type": "condition_script",
                                    "id": "isInitiator",
                                    "scriptFunction": "isInitiator"
                                },
                                {
                                    "type": "condition_service_script",
                                    "id": "chooseAIvsAIMeleeAnimations",
                                    "scriptFunction": "chooseAIvsAIMeleeAnimations",
                                    "cooldownMin": 0,
                                    "cooldownMax": 0
                                },
                                {
                                    "type": "condition_script",
                                    "id": "hasCloseAIvsAIEnemy",
                                    "scriptFunction": "hasCloseAIvsAIEnemy"
                                },
                                {
                                    "type": "action",
                                    "id": "AIvsAIMeleeAction",
                                    "ActionName": "AIvsAIMeleeAction",
                                    "ASMStateName": "void@debug",
                                    "loopingAction": 0,
                                    "actionTimeMax": 0
                                }
                            ]
                        },
                        {
                            "type": "sequence",
                            "id": "MeleeBehavior",
                            "children": [
                                {
                                    "type": "condition_script",
                                    "id": "shouldMelee",
                                    "scriptFunction": "zombieDogShouldMelee"
                                },
                                {
                                    "type": "action",
                                    "id": "meleeAction",
                                    "ActionName": "zombieDogMeleeAction",
                                    "ASMStateName": "melee@zombie_dog",
                                    "loopingAction": 0,
                                    "actionTimeMax": 0,
                                    "actionNotify": "attack_melee"
                                }
                            ]
                        },
                        {
                            "type": "parallel",
                            "id": "IdleBehavior",
                            "children": [
                                {
                                    "type": "condition_script_negate",
                                    "id": "hasPath",
                                    "scriptFunction": "locomotionBehaviorCondition"
                                },
                                {
                                    "type": "action",
                                    "id": "idleAction",
                                    "ActionName": "defaultAction",
                                    "ASMStateName": "idle@zombie_dog",
                                    "loopingAction": 0,
                                    "actionTimeMax": 0
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "type": "action",
            "id": "DebugVoidAction",
            "ActionName": "defaultAction",
            "ASMStateName": "void@debug",
            "loopingAction": 0,
            "actionTimeMax": 0
        }
    ]
}

and i want to load this up and it trees and when you open the tree you can edit whats in the blocks and create your own key values but i done a lot of research on this and not sure the best way to lay it out or how to implement it its the first time i thought of doing this and this is why i asked here for some help im sorry i have no code examples. 

解决方案

This is not a small project.  There are many parts to it.  It's not just a simple tree view, because you have to worry about objects AND lists.  And for the individual items, you'll need a way to distinguish between strings, integers, floats, booleans, and nulls.  They all have to be treated differently.

I strongly suggest you take a look at some of the open source JSON editors that already exist, and see if they wouldn't be a good starting point.

https://github.com/jdorn/json-editor

https://github.com/josdejong/jsoneditor


这篇关于杰森的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆