Example
Input
{
"name" : "udomsak",
"dataForm" : {
"attribute1": "myname is"
"gender" : "male",
"location": "Mars"
}
Parser Language
This parser language is Dynamic and does not need to compile in Struct in Golang. that mean can get from database or file use as parser.
ParserGet:
- name
- dataForm.gender
- dataForm.location
Example request
ProjectA:
http://api.example.com/parser-rule/parser1
- parser1 load from parser rule file : "parser1.rule.conf"
ProjectB:
http://api.example.com/parser-rule/parser2
- parser1 load from parser rule file : "parser2.rule.conf"
Top comments (2)
OK, what you haven't explained is that in Go, JSON parsing can occur directly into structs
With your example, this is complicated with the need for a struct inside a struct
The problem is that JSON can contain all kinds of fields and nested data and Go requires the schema to be declared ahead of time with struct declarations
However it's possible to load arbitrary JSON into Go anyway
Just load it into an empty interface
but then accessing fields in the data becomes a major pita. To achieve the same as above...
@vorsprung thank you for answer me and sorry for very lately reply. I'm so busy. But for this problem look like i must use custom parser to work with this case. ( goyacc ).
my intend is you json as form ( json form-schema ) and anyone can create they form as need. that mean in server-side they need implement custom parser to get attribute they need. :)