I have a type Positive Integer that consists of one key of type String. This is the type, it is Z10022 in my installation:
lang=javascript, lines=10
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z10022"
},
"Z2K2": {
"Z1K1": "Z4",
"Z4K1": "Z10022",
"Z4K2": {
"Z1K1": {
"Z1K1": "Z7",
"Z7K1": "Z881",
"Z881K1": "Z3"
},
"K1": {
"Z1K1": "Z3",
"Z3K1": "Z6",
"Z3K2": {
"Z1K1": "Z6",
"Z6K1": "Z10022K1"
},
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "value"
}
]
}
},
"K2": {
"Z1K1": {
"Z1K1": "Z7",
"Z7K1": "Z881",
"Z881K1": "Z3"
}
}
},
"Z4K3": "Z101"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Positive integer"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": []
}
]
}
}
```
Now I want to create a function that takes a string and returns a positive integer. This is the function definition (Z10095 in my wiki):
```lines=10; lang=json
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z10095"
},
"Z2K2": {
"Z1K1": "Z8",
"Z8K1": [
{
"Z1K1": "Z17",
"Z17K1": "Z6",
"Z17K2": {
"Z1K1": "Z6",
"Z6K1": "Z10095K1"
},
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "input"
}
]
}
}
],
"Z8K2": "Z10022",
"Z8K3": [],
"Z8K4": [
"Z10096"
],
"Z8K5": "Z10095"
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Positive Integer constructor"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": []
}
]
}
}
```
I tried several implementations, but the following ones I thought used to work but don't work anymore. So this implementation is taking the literal and placing the argument in the right place:
```lines=10; lang=json
{
"Z1K1": "Z2",
"Z2K1": {
"Z1K1": "Z6",
"Z6K1": "Z10096"
},
"Z2K2": {
"Z1K1": "Z14",
"Z14K1": "Z10095",
"Z14K2": {
"Z1K1": "Z10022",
"Z10022K1": {
"Z1K1": "Z18",
"Z18K1": {
"Z1K1": "Z6",
"Z6K1": "Z10095K1"
}
}
}
},
"Z2K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "Composition of Positive Integer constructor"
}
]
},
"Z2K4": {
"Z1K1": "Z32",
"Z32K1": [
{
"Z1K1": "Z31",
"Z31K1": "Z1002",
"Z31K2": []
}
]
}
}
```
When I do that and then I call the function like this:
```lang=json
{
"Z1K1": "Z7",
"Z7K1": "Z10095",
"Z10095K1": {
"Z1K1": "Z6",
"Z6K1": "5"
}
}
```
I get the following result:
```lines=10; lang=json
{
"Z1K1": "Z22",
"Z22K1": {
"Z1K1": {
"Z1K1": "Z4",
"Z4K1": "Z10022",
"Z4K2": [
{
"Z1K1": "Z3",
"Z3K1": "Z6",
"Z3K2": "Z10022K1",
"Z3K3": {
"Z1K1": "Z12",
"Z12K1": [
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "value"
}
]
}
}
],
"Z4K3": {
"Z1K1": "Z8",
"Z8K1": [
{
"Z1K1": "Z17",
"Z17K1": "Z1",
"Z17K2": "Z101K1",
"Z17K3": {
"Z1K1": "Z12",
"Z12K1": []
}
}
],
"Z8K2": "Z1",
"Z8K3": [],
"Z8K4": [
{
"Z1K1": "Z14",
"Z14K1": "Z101",
"Z14K4": {
"Z1K1": "Z6",
"Z6K1": "Z201"
}
}
],
"Z8K5": "Z101"
}
},
"Z10022K1": {
"Z1K1": "Z18",
"Z18K1": "Z10095K1"
}
},
"Z22K2": "Z23"
}
```
but it should be
```lang=json
{
"Z1K1": "Z10022",
"Z10022K1": "5"
}
```